I would say that it depends on whether you really need to provide your Value property as a specific TValue , where the TValue comes from Test<T> . In other words, do you need to expose the functionality available only for derived classes, or can you just expose Test<T> with all the functionality of the base class?
In the latter case, you can simplify the definition of your class:
public class Wrapper<TKey> { public Test<TKey> Value { get; set; } }
As for the exact functionality you are looking for: I do not believe that in the current version of C # something completely similar is available.
However, another option in your case might be to actually use your Wrapper class as the base class:
public abstract class Test<TKey> { TKey Key { get; set; } } public abstract class Wrapper<TValue, TKey> where TValue : Test<TKey> { public TValue Value { get; set; } } public class TestWrapper<TKey> : Wrapper<Test<TKey>, TKey> { }
source share