Documentation Center

  • Trial Software
  • Product Updates


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


Fully qualified string with the generic type name.


Allowed cell types are: strings 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.


expand all

Create a List of System.Double Objects

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

t = NET.createGeneric('System.Collections.Generic.List',...

Create a List with Key/Value Pairs

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

pe = NET.GenericClass('System.Collections.Generic.KeyValuePair',...

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

st = NET.createGeneric('System.Collections.Generic.List',...

Add an Item to the List

Create a KeyValuePair item.

kvpItem = NET.createGeneric('System.Collections.Generic.KeyValuePair',...

Add this item to the list kvpList.


See Also

Was this topic helpful?