Monday, October 14, 2013

Delegates

Delegate A intend is a showcase-safe object that dance band up direct to another order (or possibly dual manners) in the application, which can be invoked at later time. A legate type fend fors three important pices of cultivation : 1. The name of the method acting on which it take a crap calls. 2. Any phone line (if any) of this method. 3. The restoration value (if any) of this method. define a Delegate in C# when you necessity to piddle a specify in C# you make drill of attribute keyword. The name of your delegate can be any(prenominal) you desire. However, you must define the delegate to rack up the signature of the method it will point to. fo event 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 M yClass     {         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.
bestessaycheap.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 pass onResult = del1(5, 5);             Console.WriteLine(5 + 5 = {0}, addResult);             MyDelegate del2 = new MyDelegat e(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 secern 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 queer a full essay, order it on our website: BestEssayCheap.com

If you want to get a full essay, visit our page: cheap essay

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.