Constraint is condition on a type parameter that restricts the type argument you can supply for it. A constraint can require that the type argument implement a particular interface, be or inherit from a particular class, have an accessible parameterless constructor, or be a reference type or a value type. You can combine these constraints, but you can specify at most one class.
Ex:
C#
class SampleClass<T>
where T : IComparable
{
}
VB#
Class CompGen(Of T As IComparable)
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment