Re: Type alias in C#
- From: Dustin Campbell <dustinc@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 9 Nov 2006 18:50:56 +0000 (UTC)
Hi Dustin,
I think that referring to this as "one small paragraph" is quite anGood point :)
understatement. I mean, if you can't trust the definition in the
*glossary*, what can you trust?
I trust the fact that every document in the MSDN library for all FCL
ValueTypes (of course, I haven't verified ALL) explicitly state each
as "Structure" in their titles.
Except that all FCL enumerations (which are also ValueTypes) list "Enumeration" in their titles. Since enumerations are ValueTypes, that statement isn't really correct. So, why does your logic for the presence of the keyword "Structure" not apply to the presence of the keyword "Enumeration" as well? It seems like you are trying to use this title keyword to prove your point but it really seems to prove mine -- that enumerations are not "structures".
Interestingly enough, I searched the C# glossary, "struct" keyword
definition and some programming guidance documentation (all C#) but
none contained the term "structure" in any related way. (It's used to
describe a "data structure" though).
In VB.NET, as you mentioned in another post in this thread, the term
"Structure" appears to mean value-type. It's used for constraining
generic arguments. You have the choice of "Class", "Structure" or
neither keyword in VB.NET. In C#, "class", "struct" or neither
keyword may be used to constrain generic arguments after the "where"
statement.
If you use the C# keyword "struct" to constrain a generic argument you
can successfully pass in an enum value:
That indeed is a good point but that constraint is really only ensuring that a type argument will descend from System.ValueType -- not that it is a C# struct. So, its use on enumerations could simply be considered a side effect.
I just can't understand how an enum can be considered a structure when it only shares one feature of structures: stack allocation. Other features such as interface implementation and method declaration are not supported on enums. And, using your own argument, the MSDN documentation never refers to an enumeration as a "structure". Therefore, I have to conclude that enums *are* different from structs. They are different kind of entity that are also allocated on the stack. Of course, I'd really *like* to see Microsoft make enumerations more like standard structures. It seems to me that it would be extremely useful to have instances methods and interface support for enum types.
Best Regards,
Dustin Campbell
Developer Express Inc.
.
- Follow-Ups:
- Re: Type alias in C#
- From: Dave Sexton
- Re: Type alias in C#
- References:
- Re: Type alias in C#
- From: Dave Sexton
- Re: Type alias in C#
- Prev by Date: DataRow garbage collection
- Next by Date: Failed to compare two elements in the array (v1.1 vs v2.0 x64)
- Previous by thread: Re: Type alias in C#
- Next by thread: Re: Type alias in C#
- Index(es):
Relevant Pages
|