2012년 6월 19일 화요일

list


    class Program
    {
        static void Main(string[] args)
        {
            List<test> testList = new List<test>();
            testList.Add(new test() { name = "a", num = 100 });
            testList.Add(new test() { name = "b", num = 200 });

            foreach (test a in testList)
            {
                Console.WriteLine("name ={0},\n num = {1}", a.name, a.num);
            }
           
        }
    }

    public class test
    {
        public string name;
        public int num;
    }
}

list에 객체를 담아본다.

댓글 없음 :

댓글 쓰기