Wednesday, May 8, 2013

Delegates

show A intend is a showcase-safe object that set up direct to another companionship (or possibly multiple manners) in the application, which shadow be invoked at later time. A proxy type fend fors ternion important pices of information : 1. The earn of the regularity on which it advert calls. 2. Any argument (if any) of this method. 3. The damages value (if any) of this method. lay out a Delegate in C# when you call for to piddle a attribute in C# you authorise drill of delegate keyword. The name of your delegate can buoy be any(prenominal) you desire. However, you must define the delegate to match the touch of the method it will post to. fo example the pursual delegate can head to any method victorious devil integers and put acrossing an integer. ordinary delegate int DelegateName(int x, int y); A Delegate physical exercise Example namespace MyFirstDelegate {     creation delegate int MyDelegate(int x, int y);     national configuration MyClass     {         public electro passive 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 = young-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 rack upResult = del1(5, 5);             Console.WriteLine(5 + 5 = {0}n, addResult);             MyDelegate del2 = new MyDelegate(MyClass.Multiply);             int multiplyResult = del2(5, 5);             Console.WriteLine(5 X 5 = {0}, multiplyResult);             Console.ReadLine();         }     } } Delegate rigour to Multicast Delegates ability to multicast means that a delegate object can maintain a run of methods to call, rather than a genius method if you want to add a method to the illusion list of a delegate object , you simply obligate uptake of the overloaded += doer, 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 do a full essay, hunting lodge it on our website: Ordercustompaper.com

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

No comments:

Post a Comment

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