Possible Duplicate:
What is Delegate?
In C#, a delegate can be seen as both method name and type name. Is my understanding right?
like "doShow[] items = new doShow[3];" dowShow is type name. like "doshow(new Class1()....)" dosShow is a method name/
I get this conclusion by reading codes here:
public class TestDelegate
{
// define a datatype as a method taking a string returning void
public delegate void doShow(String s);
public static void Main(string[] args)
{
// make an array of these methods
doShow[] items = new doShow[3];
items[0] = new doShow(new Class1().show);
items[1] = new doShow(new Class2().display);
items[2] = new doShow(Class3.staticDisplay);
// call all items the same way
for(int i = 0; i < items.Length; i++) {
items[i]("Hello World");
}
}
}