Здравствуйте. Дело происходит в VS2005 (C#). В некотором классе:
public delegate void UInt64Delegate1(UInt64 num);
public delegate void UInt64Delegate2(UInt64 num);
public event UInt64Delegate1 UInt64Event;
Затем в методе класса пишем одно из:
UInt64Event += new UInt64Delegate1(UInt64Method);//OK
UInt64Event += new UInt64Delegate2(UInt64Method);//Compile-time error:Operator '+=' cannot be applied to operands of type 'FramesTest.Form1.UInt64Delegate1' and 'FramesTest.Form1.UInt64Delegate2'
UInt64Event += (UInt64Delegate1)(new UInt64Delegate2(UInt64Method));//Compile-time error:Cannot convert type 'FramesTest.Form1.UInt64Delegate2' to 'FramesTest.Form1.UInt64Delegate1'
UInt64Event += (UInt64Delegate1)(System.Delegate)(new UInt64Delegate2(UInt64Method)); //Run-time error: InvalidCastException: Unable to cast object of type 'UInt64Delegate2' to type 'UInt64Delegate1'.
Вопрос: почему, казалось бы, очевидно-идентичные типы данных делегатов не преобразуются друг в друга?