Export (0) Print
Expand All

Class (Visual Basic) 

Constrains a generic type parameter to require that any type argument passed to it be a reference type, or introduces a Class Statement (Visual Basic).

When you declare a type parameter for a generic type, you can impose a constraint, a set of one or more requirements that limit the type argument that can be passed to that type parameter. For more information, see "Constraints" in Generic Types in Visual Basic.

Among the possible requirements in a constraint is that the type argument must be a reference type, for example a String, array, or delegate, or an object created from a class. You specify this by including the Class keyword in the constraint.

Another possible requirement is that the type argument must be a value type, for example a structure, enumeration, or elementary data type. You specify a value type requirement by including the Structure (Visual Basic) keyword in the constraint.

You do not have to specify either Class or Structure in a constraint. You cannot specify them both in the same constraint.

The Class constraint is not the same as the Class Statement (Visual Basic).

Community Additions

ADD
Show:
© 2015 Microsoft