Where Clause (Generics)

Specifies constraints placed on generic parameters.

Syntax

Where constraint [ , constraint ]...

Parts

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

Instructions

Examples

See also