Where Clause (Generics)

Specifies constraints placed on generic parameters.

Syntax

Where constraint [ , constraint ]...

Parts

constraint
Required. One or more constraints to place on a generic parameter, each separated by a comma.
Syntax
Normal formCombined form
[ lowerBound { < | <= } ] typeParameter { < | <= } upperBound
[ lowerBound { < | <= } ] typeParameter [ { < | <= } upperBound ]
typeParameter Is { Class | Struct }
[ Is { Class | Struct } ]
typeParameter Does boundingTrait
[ Does boundingTrait ]...
typeParameter Constructor ( )
[ Constructor ( ) ]
typeParameter
One of the previously supplied generic parameters.
upperBound
The most basic class from which typeParameter can inherit.
lowerBound
The most specialized class from which typeParameter can inherit.
boundingTrait
A trait that typeParameter must implement.
Is
Specifies whether typeParameter must be a reference type (Is Class) or a value type (Is Struct).
Constructor
Specifies that typeParameter must provide a default constructor.

Remarks

Examples

See also