How can i add list data in my object?

Posted by Phsika on Stack Overflow See other posts from Stack Overflow or by Phsika
Published on 2010-06-18T06:24:50Z Indexed on 2010/06/18 6:33 UTC
Read the original article Hit count: 342

Below codes run perfectly but i want to re generate simply

 static void YeniMethodListele()
        {
            Calisan calisan = new Calisan(){ ID=1, Ad="yusuf", SoyAd="karatoprak"};
            List<Calisan> myList = new List<Calisan>();
            myList.Add(calisan);
            MyCalisan myCalisan = new MyCalisan() { list = myList };
            //myCalisan.list.Add(calisan);

            foreach (Calisan item in myCalisan.list)
            {
                Console.WriteLine(item.Ad.ToString());
            }
        }
    }

   public class Calisan
    {
        public int ID { get; set; }
        public string Ad { get; set; }
        public string SoyAd { get; set; }

    }

   public class MyCalisan
    {
        public List<Calisan> list { get; set; }
        public MyCalisan()
        {
            list = new List<Calisan>();
        }
    }
  static void YeniMethodListele()
        {
            Calisan calisan = new Calisan(){ ID=1, Ad="yusuf", SoyAd="karatoprak"};
            MyCalisan myCalisan = new MyCalisan();
            myCalisan.list.Add(calisan);

            foreach (Calisan item in myCalisan.list)
            {
                Console.WriteLine(item.Ad.ToString());
            }
        }
    }

   public class Calisan
    {
        public int ID { get; set; }
        public string Ad { get; set; }
        public string SoyAd { get; set; }

    }

   public class MyCalisan
    {
        public List<Calisan> list { get; set; }
        public MyCalisan()
        {
            list = new List<Calisan>();
        }
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET