Using generic type from other generic parameter?

I'd say this depends on whether or not you really need to expose your Value property as a specific TValue where TValue derives from Test { public Test Value { get; set; } } As for the precise functionality you're seeking: I don't believe anything quite like that is available in the current version of C That said, another option in your case might be to actually use your Wrapper class itself as a base class: public abstract class Test { TKey Key { get; set; } } public abstract class Wrapper where TValue : Test { public TValue Value { get; set; } } public class TestWrapper : Wrapper { } // ... some code somewhere var tw = new TestWrapper(); Test value = tw.Value.

I'd say this depends on whether or not you really need to expose your Value property as a specific TValue where TValue derives from Test. In other words, do you need to expose functionality available only to derived classes, or could you simply expose a Test, with all the functionality of the base class? In the latter case, you could simplify your class definition as: public class Wrapper { public Test Value { get; set; } } As for the precise functionality you're seeking: I don't believe anything quite like that is available in the current version of C#.

That said, another option in your case might be to actually use your Wrapper class itself as a base class: public abstract class Test { TKey Key { get; set; } } public abstract class Wrapper where TValue : Test { public TValue Value { get; set; } } public class TestWrapper : Wrapper { } // ... some code somewhere var tw = new TestWrapper(); Test value = tw.Value.

Test is an abstract class though, based on comments in a deleted question you can't see quite yet (if I remember my rep limits! ), the OP wants classes that inherit from Test, not the actual class itself. He wants something like Wrapper or Wrapper and TestChild actually be TestChild...I believe the answer is the same though, this doesn't exist.

But hey, maybe there's a way to get this I'm unaware of...I'm sure the IL can do it, but not sure about C#. – Nick Craver? Jun 5 '10 at 22:11.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions