I have a method where the type of an object is known ahead of time and that object (along with its type) needs to be passed into a method, for instance:
public void foo()
{
string type_of_object = "person";
person p = new person();
// insert code here
}
public T method<T>(object obj)
{
// some functions go here
return (T)...
}
Given that there could be hundreds of types that I have to deal with, I don't want to do a switch statement over each type. I can't seem to figure out how to do something along these lines:
var foo = method<person.GetType()>(p);
Any takers?