When would you us...
When would you us...
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:
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.
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 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
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào