Could I have something like this:
int x = MyMethod<int>();
string y = MyMethod<string>();
So, one method returning different types based on T. Of course, there would be logic inside the method to ensure it was returning the correct thing.
I can never get something like this to run. It complains that it can't cast the return value to T:
public static T MyMethod<T>()
{
if(typeof(T) == typeof(Int32))
{
return 0;
}
else
{
return "nothing";
}
}