Methods and Delegates in C# V2.0
One of my first posts on this blog was moaning about the method/delegate/refelection mismatch. I'm glad to see that in C# V2.0, at least one of my wishes has come true. You can implicitly convert a method to a delegate, like this:
class ConsoleApp
{
static void Main(string[] args)
{
SomeDelegate dele = SomeMethod;
dele();
}
delegate void SomeDelegate();
void SomeMethod()
{
Console.WriteLine("hello");
}
}

0 Comments:
Post a Comment
<< Home