Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • I really don't understand why can't I cast as the following: (State<Thing>)new State<T> while T : Thing! But can (Thing)new T() Commented Dec 8, 2011 at 7:23
  • 3
    @abatishchev because a SomeSpecificThing is a Thing; but it is not true that a State<SomeSpecificThing> is a State<Thing>. There is no inheritance etc. If it were a generic interface, if could potentially be IState<out Thing>, in which case the 4.0 variance rules start to apply, and then yes, there is a cast from IState<SomeSpecificThing> to IState<Thing>. Commented Dec 8, 2011 at 7:27