Why must I provide explicitly generic parameter types While the compiler should infer the type?
public static T2 Cast<T1,T2>(this T1 arg) where T2 : class where T1 : class
{
return arg as T2;
}
Sample Usage:
objOfTypeT2 = objOfTypeT1.Cast<TypeT1,TypeT2>();
Compared to my desired usage with a more intelligent compiler:
objOfTypeT2 = objOfTypeT1.Cast<TypeT2>();
or maybe I should be more intelligent :-)
Beware that I provide the return type. I want to not provide the object that I called the function on it, the method is an Extension Method.