Let's start with a very basic definition of Delegates in the real world. Delegates in the real world refer to transferring the work/tasks assigned to self to someone else. A team leader, supervisor, the manager can delegate work to his subordinate. A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked. When to use Delegate : Source: https://msdn.microsoft.com/en-us/library/ms173173.aspx Use a delegate in the following circumstances: An eventing design pattern is used. It is desirable to encapsulate a static method. The caller has no need to access other properties, methods, or interfaces on the object implementing the method. An easy composition is des...
Comments
Post a Comment