Câu hỏi phỏng vấn C#
Câu hỏi

When would you us...

Câu trả lời

Here is an answer to the C# interview question "When would you use delegates in C#?":

Delegates in C# are used to pass methods as arguments to other methods or to store methods in variables. They are useful in several scenarios:

Event Handling

Delegates are commonly used in event handling. When an event occurs, the event source calls a method on the delegate, which in turn calls the event handler method that was assigned to the delegate by the event subscriber.

Callbacks

Delegates allow you to pass a method as an argument to another method. The method passed as an argument is called a callback method and is executed by the calling method when certain conditions are met.

LINQ Queries

LINQ uses delegates extensively, particularly with the Func<> and Action<> generic delegates. When you use LINQ query expressions, the compiler translates them into method calls t...

senior

senior

Gợi ý câu hỏi phỏng vấn

middle

Why can't you specify the accessibility modifier for methods inside the Interface?

junior

What is Boxing and Unboxing?

junior

Can multiple catch blocks be executed?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào