I have been teaching myself generics and I wanted to try it out with a list but I struggled upon a problem I cant figure out how to "feed" the generic list to my method. What is the proper way to make a generic method "eat" my list? :)
Heres my code:
class Program<AnyDataType>
{
static void Main(string[] args)
{
jdtlist.Add("something");
jdtlist.Add("something");
jdtlist.Add("something");
Console.WriteLine(countlist(jdtlist));
Console.ReadKey();
}
static List<AnyDataType> jdtlist = new List<AnyDataType>();
public static int countlist(List<AnyDataType> list) // Yes I know this is practically useless but thats not why I am here :)
{
int listcount = 0;
for (int i = 0; i < list.Count; i++)
{
listcount++;
}
return listcount;
}
Count?