Why can I not use a generic base class as a property RRS feed

  • Question

  • Hi,

    I know why the following can be potentially dangerous - but I would think there would be a solution:

    I have a generic base class - like this:

    public class TestBase<T>


    Then I have two descendants:

    public class TestDescendant1 : Test<string>

    public class TestDescendant1 : Test<int>


    Now I have a class the would take a base class as input and do something with the object:

    public TestBase _testBase;

    THIS does not compile - I need to set a type of TestBase. But if I do that I will get another error.

    Is this a limitation of Generics?


    Best regards,


    Wednesday, April 28, 2010 8:13 PM