using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { ClassA<string> x1 = new ClassA<string>("I am here"); ClassA<int> x2 = new ClassA<int>(20); ClassA<DateTime> x3 = new ClassA<DateTime>(DateTime.Now); Console.WriteLine(x1.MyIndex); Console.WriteLine(x2.MyIndex); Console.WriteLine(x3.MyIndex); } } public class ClassA<T> { public T Item { get; set; } public int MyIndex { get; set; } public ClassA(T source) { Item = source; MyIndex = classIndex++; } static int classIndex = 0; } }