Tuesday, March 10, 2015

C# program that adds objects to List

using System.Collections.Generic;

class Program
{
    static void Main()
    {
 // Add three objects to a List.
 List<Test> list = new List<Test>();
 list.Add(new Test(1, 2));
 list.Add(new Test(3, 4));
 list.Add(new Test(5, 6));
    }

    class Test
    {
 int _a;
 int _b;
 public Test(int a, int b)
 {
     _a = a;
     _b = b;
 }
    };
}

No comments:

Post a Comment