Java and C# both allow similar constraints on a generic class's type
parameters. The following 'Foo' class in either Java or C# specifies that the
generic type parameter 'T' can be satisfied by any class which implements or
extends type AA and type BB:
|class Foo<T extends AA & BB>
|class Foo<T> where T : AA, BB
There is no C# equivalent to the Java 'super' constraint and there is no Java equivalent to the C# 'new' or 'class' constraints.
Copyright © 2004 – 2019 Tangible Software Solutions, Inc.