I’ve got an interface with some generic methods, and I wanted to implement a method with overloads to either accept an instance of a class, or its PK value (which is either an int or GUID but does vary).
I added to methods similar to these examples:
void DoSomething<TKey>(TKey key) where TKey: struct;
void DoSomething<TModel>(TModel model) where TModel : class;
The ‘DoSomething’ method name on the second of these is highlighted, and the error is
Type ‘ISomeStuff’ already defines a member called ‘DoSomething’ with
the same parameter types.
I’m surprised by this as I’ve clearly defined by parameters to be of different type: one is a class and the other a struct.
Why isn’t this sufficient to make the signatures different?
Jon Skeet has an answer to everything: click me
quote: