|
by Eric Lippert via Fabulous Adventures In Coding on 5/19/2008 2:01:00 PM
Here's a question I get fairly frequently: the user desires to create a generic type Bar<T> constrained such that T is guaranteed to be a Foo<U>, for some U.
The way they usually try to write this is
class Bar<T> where T : Foo<T> {...
which of course then does not work. The user discovers this when they type
new Bar<Foo<string>>()
and get an error stating that the constraint has been violated. Which it certainly has. The constraint says that T m
... [ read more ]
|