This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Package: NET

Create instance of specialized .NET generic type


genObj = createGeneric(className,paramTypes,varargin ctorArgs)


genObj = createGeneric(className,paramTypes,varargin ctorArgs) creates an instance genObj of generic type className.

Input Arguments


String or character vector containing the fully qualified generic type name.


Allowed cell types are: strings or character vectors with fully qualified parameter type names and instances of the NET.GenericClass class when parameterization with another parameterized type is needed.


Optional, variable length (0 to N) list of constructor arguments matching the arguments of the .NET generic class constructor intended to be invoked.

Output Arguments


Handle to the specialized generic class instance.


collapse all

Create a strongly typed list dblLst of objects of type System.Double.

t = NET.createGeneric('System.Collections.Generic.List',{'System.Double'},10);

Create the kvpType generic association where Key is of System.Int32 type and Value is a System.String.

kvpType = NET.GenericClass(...

Create the list kvpList with initial storage capacity for 10 key-value pairs.

kvpList = NET.createGeneric('System.Collections.Generic.List',{kvpType},10);

Create a KeyValuePair item.

kvpItem = NET.createGeneric(...

Add this item to the list kvpList.


Introduced in R2009a