Does "delegate" mean a type or an object?
Posted
by Michal Czardybon
on Stack Overflow
See other posts from Stack Overflow
or by Michal Czardybon
Published on 2009-07-28T10:37:26Z
Indexed on
2010/06/18
9:43 UTC
Read the original article
Hit count: 232
Reading from MSDN: "A delegate is a type that references a method. Once a delegate is assigned a method, it behaves exactly like that method."
Does then "delegate" mean a type or an object?!
...It cannot be both. It seems to me that the single word is used in two different meanings:
- a type containing a reference to a method of some specified signature,
- an object of that type, which can be actually called like a method.
I would prefer a more precise vocabulary and use "delegate type" for the first case. I have been recently reading a lot about events and delegates and that ambiguity was making me confused many times.
Some other uses of "delegate" word in MSDN in the first meaning:
- "Custom event delegates are needed only when an event generates event data"
- "A delegate declaration defines a class that is derived from the class System.Delegate"
Some other uses of "delegate" word in MSDN in the second meaning:
- "specify a delegate that will be called upon the occurrence of some event"
- "Delegates are objects that refer to methods. They are sometimes described as type-safe function pointers"
What do you think? Why did people from Microsoft introduced this ambiguity? Am I the only person to have conceptual problems with different notions being referenced with the same word.
© Stack Overflow or respective owner