Possible duplicate:
General restrictions where T: struct and where T: class
Is there a special reason why you cannot overload common methods using mutually exclusive type restrictions in C #? For example, take these methods:
T DoSomething<T>(T arg) where T : class { } T DoSomething<T>(T arg) where T : struct { }
and try calling them with
DoSomething("1"); DoSomething(1);
The way I see it, DoSomething () methods are mutually exclusive with respect to the parameters that they will take - the first accepts a reference type, the second accepts a value type. The compiler should be able to say that a DoSomething call with a string argument goes to the first method, and a DoSomething call with an int argument goes to the second method.
Am I missing something conceptually with generics here? Or is it just a function that has not been implemented in C #?
eouw0o83hf
source share