Results 1 to 6 of 6

Thread: Use of delegates in C sharp

  1. #1
    Join Date
    May 2008
    Posts
    2,389

    Use of delegates in C sharp

    Hello friends,

    I am IT student, and I want to share my query with you about the C sharp programming. I am not able to understand the use of delegates in C sharp programming language. The concept of delegates are quit tough to understand, as it's very complicated concept. If anyone has the sound knowledge about the C sharp delegates then please let me know the use of delegates in C sharp. I am waiting for your reply.

  2. #2
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Use of delegates in C sharp

    Delegates in C # are equivalent to function pointers in C / C + + but also secure (type-safe). Simplifying, one can say that a delegate is a pointer to a method but is much more than that. The mechanism that delegates use easily handles the asynchronous treatment but also offers other advantages. A delegate is an intermediary between a transmitter and a receiver, it allows to establish a contract between them. It is a means of communication between objects that do not necessarily know. Delegates are used in the environment.

  3. #3
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Use of delegates in C sharp

    The concept of delegate could be compared to that interface because an interface is a contract between classes except that a delegate does his contract with a method and not a class. What is the contract of a delegate? It is during the reporting thereof to completely specify a method's parameters, their number, type and return type of method. A delegate actually stores the address of a method that is contained in some other class. So, a C sharp delegate is really the equivalent of a function pointer in C++. However, they are also far more than that.

  4. #4
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Use of delegates in C sharp

    Hi,

    C sharp delegates used in the following conditions:
    • It is desirable to encapsulate a static method.
    • On the object that implements the method.
    • Ease of composition is desired.
    • A class may need several implementations of the method.
    • The caller does not need access to other properties, methods or interfaces
    • A model of event design is used.

  5. #5
    Join Date
    May 2008
    Posts
    2,012

    Re: Use of delegates in C sharp

    Delegates are extremely useful in multithreading and cross-thread operations. The delegates and interfaces allows designer of class to separate type declarations and implementation. A Delegate can be created for a method of any class, as the method fits the method signature for the delegate. Delegates are used to ensure that developers write code to handle certain features without knowing or needing to understand the original underlying code.

  6. #6
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Use of delegates in C sharp

    Hi friends,

    The use of delegates is to create classes, user controls or components independent of each other (known to weak coupling), which facilitates code reuse and all that follows: maintenance, development & publication. Using a delegate needs to declare a variable of the delegate type to use.Delegates & function pointers are used to ensure that developers write code to handle certain features without knowing or needing to understand the original underlying code.

Similar Threads

  1. Sharp 007SH Hybrid An 3D Clamshell Android Phone by Sharp
    By jackalz in forum Web News & Trends
    Replies: 3
    Last Post: 22-05-2011, 07:28 AM
  2. What is the difference between Events and Delegates in C#?
    By Whos*Daksha in forum Software Development
    Replies: 4
    Last Post: 26-12-2010, 12:36 AM
  3. What is the difference between delegates and interfaces?
    By Rum in forum Software Development
    Replies: 5
    Last Post: 22-01-2010, 02:00 PM
  4. Multicast delegates of C sharp
    By Truster in forum Software Development
    Replies: 5
    Last Post: 21-01-2010, 11:03 AM
  5. What do you mean by Csharp Delegates?
    By Jarini in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 09:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,581,991.22464 seconds with 17 queries