what is current situations or secnarios it must use delegate ?

ahmed salah 3,216 Reputation points
2022-11-21T01:31:47.7+00:00

I working on csharp i need to know what is current situations and scenarios it must use delegate on it
i talk generally without code
i mean cases it must use delegate and event

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,114 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 24,611 Reputation points Microsoft Vendor
    2022-11-21T09:01:13.01+00:00

    @ahmed salah , Welcome to Microsoft Q&A, you could refer to the following link to know when we should the delegate.

    When would you use delegates in C#?

    Including the following points:

    1. Event handlers (for GUI and more)
    2. Starting threads
    3. Callbacks (e.g. for async APIs)
    4. LINQ and similar (List.Find etc)
    5. Anywhere else where I want to effectively apply "template" code with some specialized logic inside (where the delegate provides the specialization) i mean cases it must use delegate and event

    If you mean that you want to use event, it is often used in GUI app. (First Point)

    Hope my explanation could help you.

    Best Regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.