I have my generic class and two methods that accept as argument a delegate (generic or not)
public sealed class MyClass<TResult>
{
public MyClass ContinueWith(ThreadInfo.Parameterized arg)
{
}
public MyClass<TResult> ContinueWith<TResult>(ThreadInfo<TResult>.Parameterized arg)
{
}
}
Where:
public sealed class MyClass
{
}
I have the Compiler Warning (level3) CS0693 but if I remove <TResult> from the second method:
public MyClass<TResult> ContinueWith(ThreadInfo<TResult>.Parameterized arg)
I can’t use this method anymore, if I try I get a compiler error because the compiler thinks I want to use the first method.
How can I solve this problem?
Well it sounds like you really want:
In other words, using the
TResultparameter declared at the type level.If you really want it to be a generic method (i.e. introducing a new type parameter) you have to give it a different name:
(It’s possible that you may want to return a
MyClass<TResult>here, or something similar – we don’t really know what you’re trying to achieve, which makes it hard to give detailed help.)