Sunday, October 11, 2015

Why delegate is categorized as TYPE in C#?

We believe many people have this wonder, but none seems to raise it yet, based on our observations so far.

Its easy to understand that Class, Struct, Enum, and Interface are Types as they share pretty similar appearance and behavior, e.g. having a declaration header and a body, having some members, starting with a curly and ending with another, etc. However, Delegate is very different. It is generally declared with a single line ending with a colon. It does not have any members or fields. Instead, it has return type and one or more parameters, pretty much like methods.

It should not surprise people since they are nothing but method representers, method pointers, method delegates or whatsoever. The thing is it is of type CodeType in the EnvDTE! That caused many coding issues for programmers, we believe. Maybe delegate should belong to a new group that only has itself!

FREE Download and Try Visual Smarter 2015

No comments:

Post a Comment