Could you please clarify for me the question asked here.
Why it is important that originally defined class:
public class Metadata<DataType> where DataType : struct
{
private DataType mDataType;
}
Thanks & Regards, Milan.
Each generic type instantiation is a new type. i.e MetaData<int>
is a different type than MetaData<bool>
.
The compiler generates a type like this (inspect using .Net refelector)
Namespace.Metadata`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]
So you cannot declare a List of heterogeneous types. You can only declare a List of one type. Hence it is necessary to make all generic MetaData<> classes to be inherited from an abstract class or interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With