On May 8, 11:41 am, Navaneeth.K.N
<Navaneet...@discussions.microsoft.comwrote:
I know structure is a value type and derived from System.ValuType. So I have
the following questions,.
1 - C# won't allow to derive one structure from other. Then how come it is
derived from System.ValueType ?
The details of how value types fit into the type hierarchy are
somewhat murky and involve being *very* precise with terminology. Here
there's no particular conflict, however: System.ValueType isn't a
value type itself, it's a reference type - so the "you can't derive
from value types" rule remains intact.
2 - I have written a simple C# console application. Following is the
equivalent IL code which is generated for the structure
.class sequential ansi sealed nested private beforefieldinit MyStruct
extends [mscorlib]System.ValueType
{
}
In this it is showing as class. How this is possible ?
Because ".class" doesn't mean what you think it does (and what most
people would naturally think it does).
".class" is used to declare various kinds of types:
From ECMA 335:
<quote>
[Rationale: For historical reasons, many of the syntactic categories
used for defining types incorrectly use
“class” instead of “type” in their name. All classes are types, but
“types” is a broader term encompassing value
types, and interfaces as well. end rationale]
</quote>
Jon