Why does this not work? Do I not understand delegate covariance correctly?
public delegate void MyDelegate(object obj)
public class MyClass
{
public MyC
You need to use a generic.
EDIT: Why? Because as another poster noted, Object and SomeObject do not equate to the same thing as Object may not be SomeObject. This is the whole point of Generics in the language.
public delegate void MyDelegate(T obj)
public class MyClass
{
public MyClass()
{
_delegate = MyMethod;
}
private MyDelegate _delegate;
public void MyMethod(SomeObject obj)
{
}
}