A
Adam Clauss
I feel like the compiler should be able to infer the type of the
parameter to this generic delegate, but it requires me to specify the
type parameter. Am I just "wrong", or did I do something wrong in the
definition/use?
public delegate void MyDelegate<TSomeType>(TSomeType a);
public class MyClass
{
public void useDelegate<TSomeType>(MyDelegate<TSomeType> del)
{
}
public void a()
{
useDelegate(delegateMethod); // *** THROWS ERROR CS0411
useDelegate<string>(delegateMethod); // COMPILES OK
}
public void delegateMethod(string str)
{
}
}
Thanks,
Adam
parameter to this generic delegate, but it requires me to specify the
type parameter. Am I just "wrong", or did I do something wrong in the
definition/use?
public delegate void MyDelegate<TSomeType>(TSomeType a);
public class MyClass
{
public void useDelegate<TSomeType>(MyDelegate<TSomeType> del)
{
}
public void a()
{
useDelegate(delegateMethod); // *** THROWS ERROR CS0411
useDelegate<string>(delegateMethod); // COMPILES OK
}
public void delegateMethod(string str)
{
}
}
Thanks,
Adam