That\'s a pretty elementary question, but I have never delved into generics before and I found myself in the need to use it. Unfortunately I don\'t have the time right now to go
You need to declare T
against the method, then C# can identify the type the method is receiving. Try this:
void MyMethod(List list){
//Do stuff
}
Then call it by doing:
if (someCondition)
MyMethod(list1);
else
MyMethod(list2);
You can make it even stricter, if all classes you are going to pass to the method share a common base class:
void MyMethod(List list) where T : MyClassBase