Exploring Delegates

Introduction

Delegates are a kind of type safe function pointers which are actually declared as class derived from System.MulticastDelegate. There are few rules how to write that class. First you must declare .ctor and Invoke methods, if you like to have asynchronous callback involved there are two more methods just for that case BeginInvoke and EndInvoke. Except for these two or four methods nothing else should be declared and these declarations must be without implementation (empty body). This is what it looks like:

    .method public hidebysig specialname rtspecialname 
    instance void .ctor(object 'object',
    native int 'method') runtime managed
    {
    } // end of method WildCard::.ctor

    .method public hidebysig virtual instance int32 
    Invoke() runtime managed
    {
    } // end of method WildCard::Invoke 

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Nine people can't make a baby in a month.” - Fred Brooks