Library tutorials & articles

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 

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of Exploring Delegates.

Leave a comment

Sign in or Join us (it's free).

Filip Bulovic

Related podcasts

  • Object-Oriented Programming in Ruby

    In this episode, I talk with Scott Bellware about object-oriented programming in Ruby, and Ruby's object model. This is taken from a private conversation, and the audio quality suffers at times. Much thanks to Scott for allowing this to be released.This episode of the Alt.NET Podcast is bro...

We'd love to hear what you think! Submit ideas or give us feedback