.

Sunday, September 15, 2013

Delegates

Delegate A intend is a showcase-safe object that erect up direct to another order (or possibly ninefold manners) in the application, which can be invoked at later time. A doom type fend fors three important pices of development : 1. The name of the system on which it drop calls. 2. Any lineage (if any) of this method. 3. The restoration value (if any) of this method. define a Delegate in C# when you compulsion to piddle a specify in C# you make drill of delegate keyword. The name of your delegate can be any(prenominal) you desire. However, you must define the delegate to find out the signature of the method it will point to. fo physical exercise the following delegate can point to any method taking devil integers and returning an integer. public delegate int DelegateName(int x, int y); A Delegate physical exercise Example namespace MyFirstDelegate {     public delegate int MyDelegate(int x, int y);     public class MyClass     {         public electrostatic int Add(int x, int y)         {             return x + y;         }         public static int Multiply(int x, int y)         {             return x * y;         }     }     class Program     {         static void Main(string[] args)         {             MyDelegate del1 = new-fangled MyDelegate(MyClass.
Ordercustompaper.com is a professional essay writing service at which you can buy essays on any topics and disciplines! All custom essays are written by professional writers!
Add);             int summateResult = del1(5, 5);             Console.WriteLine(5 + 5 = {0}, addResult);             MyDelegate del2 = new M yDelegate(MyClass.Multiply);        !      int multiplyResult = del2(5, 5);             Console.WriteLine(5 X 5 = {0}, multiplyResult);             Console.ReadLine();         }     } } Delegate cogency to Multicast Delegates ability to multicast means that a delegate object can maintain a find of methods to call, rather than a single method if you want to add a method to the conjury list of a delegate object , you simply make uptake of the overloaded += operator, and if you want to remove a method from the invocation list you make use of the overloaded operator -= . notational system:...If you want to uprise a full essay, order it on our website: OrderCustomPaper.com

If you want to get a full essay, visit our page: write my paper

No comments:

Post a Comment