P
Pierre Arnaud
I'd like to provide two generic methods with the same name and
the same arguments, but with different constraints, such as:
void Explore<T>(T[] a, T[] b) where T : struct { }
void Explore<T>(T[] a, T[] b) where T : class { }
The value types should use the first method and the reference types
the second method. However, this won't compile, as the C# compiler
reports that there is already a method defined with the same name
and the same arguments.
Constraints seem not to be taken in account !?
Is there some other means of handling value and reference types
in different methods automatically ? I can't see one with generics
in C#. But I might have overlooked something.
Pierre
http://www.creativedocs.net/
the same arguments, but with different constraints, such as:
void Explore<T>(T[] a, T[] b) where T : struct { }
void Explore<T>(T[] a, T[] b) where T : class { }
The value types should use the first method and the reference types
the second method. However, this won't compile, as the C# compiler
reports that there is already a method defined with the same name
and the same arguments.
Constraints seem not to be taken in account !?
Is there some other means of handling value and reference types
in different methods automatically ? I can't see one with generics
in C#. But I might have overlooked something.
Pierre
http://www.creativedocs.net/