I know we cannot do this at class level but at method level we can always do this.
var myList=new List // or something else like this
<
Pass List Type in Generic
class Class1
{
public void genmethod(T i,int Count)
{
List list = i as List;
for (int j = 0; j < Count; j++)
{
Console.WriteLine(list[j]);
}
}
static void Main(string[] args)
{
Class1 c = new Class1();
c.genmethod("str",0);
List l = new List();
l.Add("a");
l.Add("b");
l.Add("c");
l.Add("d");
c.genmethod>(l,l.Count);
Console.WriteLine("abc");
Console.ReadLine();
}
}