Tangible Software Solutions

The Most Trusted Name in Source Code Conversion

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:

class Foo<T extends AA & BB>
{
}

C#:

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.

If you need to convert between C# and Java and you are depending on the results being reliable and accurate, then you will want to have C# to Java Converter, the best C# to Java converter, or Java to C# Converter, the best Java to C# converter, at your fingertips.

Copyright © 1997 - 2017 Tangible Software Solutions Inc.