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

Invoke generic method of object


[varargout] = NET.invokeGenericMethod(obj,'genericMethodName',paramTypes,args,...)


[varargout] = NET.invokeGenericMethod(obj,'genericMethodName',paramTypes,args,...) calls instance or static generic method genericMethodName.

Input Arguments


Allowed argument types are:

  • Instances of class containing the generic method

  • Strings or character vectors with fully qualified class name, if calling static generic methods

  • Instances of NET.GenericClass definitions, if calling static generic methods of a generic class


Generic method name to invoke


Cell vector (1 to N) with the types for generic method parameterization, where allowed cell types are:

  • Strings or character vectors with fully qualified parameter type name.

  • Instances of NET.GenericClass definitions, if using nested parameterization with another parameterized type


Optional, variable length (0 to N) list of method arguments

Output Arguments


Variable-length output argument list, varargout, from method genericMethodName


The following syntax calls a generic method that takes two parameterized types and returns a parameterized type:

a = NET.invokeGenericMethod(obj, ...
  'myGenericSwapMethod', ... 
  {'System.Double', 'System.Double'}, ...
  5, 6);

To display generic methods in MATLAB®, see the example Display .NET Generic Methods Using Reflection.

Introduced in R2009b

Was this topic helpful?