Why is it not possible to declare a non-sealed or abstract enum, struct, or delegate?
As many of us know, the System.Type type defined in the System namespace as well as the types defined in the System.Reflection namespace make it possible to easily search for abstract types of different variety of types, such as structs, enums, classes, etc.
With that in mind, I was using reflection the other day and 'discovered' that in the framework class library there are several abstract structs. Some of them most of us have never heard of and will never be able to directly access, because they are not public. For example, System.EnterpriseServices.Thunk.IServiceCall. The name of this type gives it away as an interface, but according to reflection it is a struct, and it is also sealed, meaning that it's probably not an interface, since being sealed, unless I'm mistaken, would sort of kill the raison d’Ítre of an interface.
Also, if you are using a .Net 3.5, you might have noticed that the type from which all enumeration types derive, System.Enum, is listed as a struct, and it clearly is abstract, since it cannot be instantiated, and not sealed, since that's the type all enumeration types derive from. As far as I know this is the only struct that is not sealed.
To add to the confusion, in .Net 4.0 the System.Enum type is listed as an abstract class, and this can be confirmed by compiling the following code using .Net 4.0:
But if the same code is compiled using .Net 3.5, then both isClass and isValueType evaluate to False, as do IsInterface and IsEnum. It clearly is not a delegate, since it does not derive from System.Delegate, but since according to the .net 3.5 documentation it is a struct, then I suppose that either that's what it is or the documentation/metadata for this type is incorrect, which might explain why reflection indicates that it is neither a value type, a class, an interface, nor a delegate. It might also explain why in both .Net 3.5 and .Net 4.0 the following expression evaluates to true:
On a related note, System.MulticastDelegate is listed in both .net 3.5 and 4.0 as an abstract, non-sealed delegate, which seems to make sense but makes one wonder why application code cannot declare abstract delegate types.
Console.WriteLine(default(System.Enum) == null);//True
And concerning abstract enums? I didn't find any!
In conclusion, I'm not sure if I should even ask why application code can't declare abstract delegates or structs, but can someone clear up the confusion concerning the type classification of System.Enum and also help me understand why application code, unlike FCL code, cannot declare non-sealed delegate and struct types? Is there a reason for this or is it mere convention? Additionally, can someone offer some comments concerning the non-public, abstract, sealed System.EnterpriseServices.Thunk structs I mentioned above? If those types in fact are structs, are they like a kind of "static" struct? And if that's what they are, why can't the application code declare the same kind of struct? :)