🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Burak Kemal KOYUNCU / C# / list ile sinif kullanımı

1-) C# - list ile sinif kullanımı

 

 

using RamoClass.Model;

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

 

namespace RamoClass

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

 

            Ogrenci ogrenci = new Ogrenci();

            ogrenci.yas = 33;

            Ogrenci.sinifOzelligi = "ahmet";

 

            Ogrenci ogrenci2 = new Ogrenci();

            ogrenci2.yas = 25;

            Ogrenci.sinifOzelligi = "hasan";

            ogrenci2.yas = 37;

 

 

            List<Ogrenci> ogrencis = new List<Ogrenci>();

            ogrencis.Add(ogrenci);

            ogrencis.Add(ogrenci2);

 

            for (int i = 0; i < ogrencis.Count; i++)

            {

                Ogrenci aa = ogrencis[i];

 

                Console.WriteLine(aa.yas);

            }

 

            foreach (Ogrenci ogrenciNesnesi in ogrencis)

            {

                Console.WriteLine(ogrenciNesnesi.yas);

            }

 

        }

    }

}

 

 

namespace RamoClass.Model

{

    public class Ogrenci

    {

        public int yas;

        public static string sinifOzelligi;

    }

}

 

 2021 Ocak 21 Perşembe
 354