Skip to Main Content Skip to Search
Product Documentation

Examples Using .NET Methods

Work with .NET Methods Having Multiple Signatures

To create the NetSample assembly, see Building a .NET Application for MATLAB Examples.

The SampleMethodSignature class defines the three constructors shown in the following table.

Return TypeNameArguments
netdoc.SampleMethodSignature objSampleMethodSignature 
netdoc.SampleMethodSignature objSampleMethodSignature(double scalar d)
netdoc.SampleMethodSignature objSampleMethodSignature(System.String s)

 SampleMethodSignature Class

Display Function Signature Example

If you have not already loaded the NetSample assembly, type:

NET.addAssembly('c:\work\NetSample.dll')

Create a SampleMethodSignature object obj:

obj = netdoc.SampleMethodSignature;

To see the method signatures, type:

methods(obj, '-full')

Look for the following signatures in the MATLAB output:

netdoc.SampleMethodSignature obj SampleMethodSignature
netdoc.SampleMethodSignature obj SampleMethodSignature(double scalar d)
netdoc.SampleMethodSignature obj SampleMethodSignature(System.String s)

For more information about argument types, see Handling Data Returned from a .NET Object.

Calling Methods Examples

To create the NetSample assembly, see Building a .NET Application for MATLAB Examples.

The SampleMethods class defines the following methods:

 SampleMethods Class

Load the NetSample assembly:

NET.addAssembly('c:\work\NetSample.dll')

Call .NET Methods That Use the out Keyword

To capture the output from a method using the out keyword, use the outTest method. Its function signature is shown in the following table.

Return TypeNameArguments
double scalar db2outTest( netdoc.SampleMethods this,
double scalar db1)

Type:

obj = netdoc.SampleMethods;
db3 = outTest(obj,6)
db3 =
   14.1000

Call .NET Methods That Use the ref Keyword

To capture the output from a method using the ref keyword, use the refTest method. Its function signature is shown in the following table.

Return TypeNameArguments
double scalar db1refTest( netdoc.SampleMethods this,
double scalar db1)

Type:

obj = netdoc.SampleMethods;
db4 = refTest(obj,6)
db4 =
    12

Call .NET Methods That Use the params Keyword

To call a method using a params keyword, use the paramsTest method. The function signature is shown in the following table.

Return TypeNameArguments
int32 scalar RetValparamsTest( netdoc.SampleMethods this,
System.Int32[] num)

Type:

obj = netdoc.SampleMethods;
mat  = [1, 2, 3, 4, 5, 6];
db5 = paramsTest(obj,mat)
db5 =
          21
  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS