nerdexam
Microsoft

98-372 · Question #74

What is the purpose of using a delegate in the context of .NET Framework 4.0?

The correct answer is D. To enable an assembly to respond to an event that takes place inside a class. An assembly declares a delegate when it needs to respond to an event that takes place inside a class. A delegate is a form of type-safe function pointer used by the .NET Framework. It specifies a method to call and optionally an object to call the method on. It is used, among…

Understanding Methods and Events

Question

What is the purpose of using a delegate in the context of .NET Framework 4.0?

Options

  • ATo provide identical member methods and properties from numerous associated classes
  • BTo copy member methods and properties from an existing class
  • CTo generate an additional thread to provide parallel processing
  • DTo enable an assembly to respond to an event that takes place inside a class

How the community answered

(32 responses)
  • A
    9% (3)
  • B
    3% (1)
  • C
    16% (5)
  • D
    72% (23)

Explanation

An assembly declares a delegate when it needs to respond to an event that takes place inside a class. A delegate is a form of type-safe function pointer used by the .NET Framework. It specifies a method to call and optionally an object to call the method on. It is used, among other things, to implement callbacks and event listeners. It encapsulates 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. Answer: C is incorrect. Delegates are not related to threading. Answer: A is incorrect. Interfaces provide identical members from numerous associated classes, Answer: B is incorrect. Inheritance copies members from an existing class, not a delegate.

Topics

#delegates#event handling#method reference#event-driven programming

Community Discussion

No community discussion yet for this question.

Full 98-372 Practice