If you like you may delete hidebysig and everything will still working. Do not
delete anything else. First argument supplied to .ctor is instance of the class
that defines the target method and second is pointer to the method to be called.
Following is more in conformance with materials available from Microsoft: .method public specialname rtspecialname
instance void .ctor(object Instance, void * Method) runtime
managed
{
} // end of method WildCard::.ctor
.method public virtual instance int32
Invoke() runtime managed
{
} // end of method WildCard::Invoke
Type of Invoke must match type of method to be called, also list of parameters
and their respective types must match. BeginInvoke must be of return type System.IAsyncResult
.
It accepts three parameters:the first is the same as that being used to call
Invoke, type of second is System.AsyncCallback
and third is the
same as first parameter from .ctor. EndInvoke returns and accepts the same as
Invoke plus one extra parameter of type System.IAsyncResult
. Now
we have all the definitions. Since we are planning to use debugger create shortcut
in your “SendTo” folder and point it to "C:\Program Files\Microsoft.NET\FrameworkSDK\GuiDebug\DbgCLR.exe
".
As always we will first write some code in high level language and disassemble
P.E. to see what is going on. Save following as example.cs:using System;
delegate int WildCard();
class Worker
{
int m_w;
public Worker(int w)
{
m_w=w;
}
public int Multiply()
{
return 2*m_w;
}
}
class User
{
public static void Main()
{
int c=2;
Worker w=new Worker(c);
WildCard v=new WildCard(w.Multiply);
Console.WriteLine("Argument is {1}\nResult
is {0}",v(),c);
}
}
Exploring Delegates
- Introduction
- An Example
- Running the example
- Assembly Code
An Example
You might also like...
C# books
-
Beginning ASP.NET 2.0 E-Commerce in C# 2005: From Novice to Professional
You will learn how to build a complete e-commerce web site, following the entire design and build process. The website will be constructed following industry best practices in a modular manner&emdash;with a new module introduced and completed in each...
C# forum discussion
-
USB Drive Activity Logger!
by coque0912 (7 replies)
-
Exporting data from a repeater to an Excel sheet
by TomBlack (28 replies)
-
Calculate Date of Birth from Age
by k.prashanth (7 replies)
-
Windows Service, getting outOf memory exception
by programmerdude2341 (3 replies)
-
How to Make Default Button?
by puspitaonlinebooks (24 replies)
C# podcasts
-
.NET Rocks: Stories from CodeMash!
Published 8 years ago, running time 0h56m
While at CodeMash, Carl and Richard collected some great stories. First up is Evan Huack, who digs into cudafy, a library on codeplex that allows you to run C# code (any IL code actually) on your GPU. The second story is about Jessie Shternshus and her company The Improv Effect. Jessie talks abou.
C# jobs
-
.NET, C#, MVC Senior Software Developer
Frontline Technologies, Inc. in Exton, United States
-
C#, JQuery, KnockoutJs. Nhibernate. Unique 3-6 month opportunity in Kitesurfing/Windsurfing heaven
RWI in Cabarete, Dominican Republic
$12,000-12,000 USD per year (Contract) -
C# / .NET Programmer
Mews Systems in Prague, Czech Republic
-
Experienced C# Developer
Zenco Systems Ltd in Rugby, United Kingdom
Annual Bonus, Annual Salary Review, Perfomance Related Bonus
Comments