More complicated generic class (unbound generic type with constraint) with generic methods. It is used to demonstrate how to create cref links for generic members.

Namespace: SampleClassLibrary
Assembly: SampleClassLibrary (in SampleClassLibrary.dll)

Public Class GenericClass(Of  _ 
T1 As IComparer, _ 
T2)
This language is not supported or no code example is available.
public class GenericClass<T1, T2> 
where T1 : IComparer
This language is not supported or no code example is available.
type GenericClass<'T1, 'T2 
when 'T1 :> IComparer> = class end
This language is not supported or no code example is available.
generic<typename T1, typename T2> 
where T1 : IComparer
public ref class GenericClass
This language is not supported or no code example is available.
JScript does not support generic types and methods.
This language is not supported or no code example is available.

Type Parameters

T1

The first type parameter.

T2

The second type parameter.

Name Description
Public method Equals(Object) Determines whether the specified object is equal to the current object. (inherited from Object).
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (inherited from Object).
Public method GetHashCode Serves as the default hash function. (inherited from Object).
Public method GetType Gets the Type of the current instance. (inherited from Object).
Protected method MemberwiseClone Creates a shallow copy of the current Object. (inherited from Object).
Public method Mm1(List<Int32>[]) A method with a parameter of constructed type (bound generic type).
Public method Mm2(List<T1>) A method with a parameter of generic type from the owner class.
Public method Mm3(List<T2>) A method with a parameter of generic type from the owner class.
Public method Mm4<T3>(List<T2>) A generic method with a parameter of generic type from the owner class.
Public method ToString Returns a string that represents the current object. (inherited from Object).
Top
Name Description
Public class NestedGenericClass<T3> A nested generic class (unbound generic type).
Top

The link to this member has the following syntax:

<see cref="T:SampleClassLibrary.GenericClass`2"/>

Generics nomenclature

Generic types introduce and use the following terms:

  • Unbound Generic Type - A definition of a class, structure, interface, procedure, or delegate for which you supply at least one data type when you declare it. An unbound generic type is not itself a type, and cannot be used as the type of a variable, argument or return value, or as a base type. The only construct in which an unbound generic type can be referenced is the typeof expression. 
    public class List<T>
  • Type Parameter - In an unbound generic type definition, a placeholder for a data type you supply when you declare the type. 
    public class List<T>
  • Type Argument - A specific data type that replaces a type parameter when you declare a constructed type from an unbound generic type. 
    public class List<int>
  • Constraint - A condition on a type parameter that restricts the type argument you can supply for it. A constraint can require that the type argument must 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. 
    public class genericClass where T : System.Collections.IComparer
  • Constructed Type (bound generic type) - A class, structure, interface, procedure, or delegate declared from an unbound generic type by supplying type arguments for its type parameters. 
    public class List<int>

Rules for the cref syntax:

  • Type parameters in unbound types are replaced by `number_of_params
  • Type parameters in unbound non-types (methods, props, ...) are replaced by ``number_of_params
  • Type arguments are enclosed inside { }. Moreover, if type argument is a type parameter of containing class(es), it is replaced by its index starting from zero prepended by `. This index is agregated from outermost class, it isn't set to zero in nested generic class.
  • Constraints are removed.
SampleClassLibrary.GenericClass(Of T1, T2)

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Core

Supported in: 1.0, 1.1, 2.0

.NET Standard

Supported in: 2.0

Xamarin.Android

Supported in: 7.1

Portable Class Library

Supported in: Portable Class Library