I have the following situation below. This code will throw a compiler error for Test2
The type 'InheritedChild' cannot be used as type parameter 'T' in the generic type or method 'panelGenericIOGrid'. There is no implicit reference conversion from 'InheritedChild' to 'SerializerBase'.
public class SerializerBase<T>
{
}
public class DirectChild : SerializerBase<DirectChild>
{
}
public class InheritedChild : DirectChild
{
}
public class panelGenericIOGrid<T> : UserControl
where T: SerializerBase<T>, new()
{
}
...
panelGenericIOGrid<DirectChild> test;
panelGenericIOGrid<InheritedChild> test2;
...
I'm pretty convinced my implentation is funadmentally wrong. I want the following situation, both DirectChild and InheritedChild will give their appropriote type to the SerializerBase constuctor.
How do I get the code to work the way it needs to? Thanks!
Some info on the actual information. SerializerBase has a set of static functions that are implemented to automatically serialize and deserialize themselves based on their type.
DirectChild has a set of strings that are going to be stored on disk and recovered.
Inhertiedchild has all the members of DirectChild plus more.
Basically I'm going to need DirectChild.Serialize(filename), and IndirectChild.Serialize(filename), where the Serialize is a public member of SerializeBase