Suppose I have a basic inheritance structure:
public class Letter {...}
public class A : Letter {...}
public class B : Letter {...}
public class C : Letter {...}
public class Number {...}
public class One : Number {...}
I want to define an array of Type
s such that only Type
s which inherit from Letter
are valid. So a sample array might look like:
(type)[] myArray = new (type)[] {typeof(A), typeof(B), typeof(C)};
But the assignment
myArray[0] = typeof(One);
would fail. Is it possible to define such a structure?