Tuesday, 14 February 2012

DELEGATES

Delegates:

Delegates are types that they describes the signature of the method.delegates give reference to a function or method.

A delegate declared by delegate keyword.

We must declare the parameters through delegate.

Example:

Class delegateExample

{

delegate int D(string s);

Public int A()

{

return 0;

}

Public int B()

{

return 0;

}

Public void static void main(string []args)

{

D d1=new D(A);

D d2=new D(B);

String mystring=”hello world”;

d2(mystring);

d1(mystring);

}

}

No comments:

Post a Comment