Top "Type-constraints" questions

Constraints can be associated with a type parameter of a generic.

What does "where T : class, new()" mean?

Can you please explain to me what where T : class, new() means in the following line of code? void Add&…

c# generics type-constraints
How to define generic type limit to primitive types?

I have the following method with generic type: T GetValue<T>(); I would like to limit T to …

c# .net generics type-constraints
Why does a generic type constraint result in a no implicit reference conversion error?

I have created a couple of interfaces and generic classes for working with agenda appointments: interface IAppointment<T> …

c# generics implicit-conversion type-constraints
C# generic "where constraint" with "any generic type" definition?

Let me give example: I have some generic class/interface definition: interface IGenericCar< T > {...} I have another class/…

c# generics where type-constraints
What do <:<, <%<, and =:= mean in Scala 2.8, and where are they documented?

I can see in the API docs for Predef that they're subclasses of a generic function type (From) => To, …

scala scala-2.8 type-constraints
Specifying constructor constraint for Generic Parameter

I have a collection of objects which I pass as parameter to create objects of another type (one for one). …

c# generics extension-methods type-constraints
Why am I getting a generic constraint violation at runtime?

I'm getting the following exception while trying to create a new instance of a class that heavily relies on generics: …

c# .net generics runtime type-constraints
Subtype in Scala: what is "type X <: Y"?

Can anyone explain the subtype(<:) in the following code? Why it could be used like that? When we use …

scala type-constraints subtype
C# generic methods, type parameters in new() constructor constraint

Is there a way to create a Generic Method that uses the new() constructor constraint to require classes with constructors …

c# .net generics type-constraints