• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

Generic Class Constraints in Java and C#

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:

Java C#
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.

Use C# to Java Converter and Java to C# Converter to convert between Java and C#.     

Copyright © 2004 – 2021 Tangible Software Solutions, Inc.