In Java
, I can do that:
class JavaClass<A, B>{
A first;
B second;
}
And then declare an array, a list, or a single object of that type, without supplying generic parameters. They're being automatically converted to Object
's, like in an example below:
JavaClass someArray = new JavaClass[4];
Now, the type of someArray[0].first
is Object
.
In C#
, it doesn't seem to work:
class Leaderboard<UserType, UIEntry>
where UserType : User
where UIEntry : UserUIEntry{}
And the declaration:
Leaderboard someLeaderboard = new Leaderboard();
Gives:
Using the generic type Leaderboard requires two type arguments.
Is there any equivalent to make this work and allow me to declare that?