| Contents | Index |
| On this page… |
|---|
Work with .NET Methods Having Multiple Signatures Call .NET Methods That Use the out Keyword |
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 Type | Name | Arguments |
|---|---|---|
| netdoc.SampleMethodSignature obj | SampleMethodSignature | |
| netdoc.SampleMethodSignature obj | SampleMethodSignature | (double scalar d) |
| netdoc.SampleMethodSignature obj | SampleMethodSignature | (System.String s) |
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.
To create the NetSample assembly, see Building a .NET Application for MATLAB Examples.
The SampleMethods class defines the following methods:
refTest
outTest
paramsTest
Load the NetSample assembly:
NET.addAssembly('c:\work\NetSample.dll')
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 Type | Name | Arguments |
|---|---|---|
| double scalar db2 | outTest | ( netdoc.SampleMethods this, double scalar db1) |
Type:
obj = netdoc.SampleMethods; db3 = outTest(obj,6)
db3 = 14.1000
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 Type | Name | Arguments |
|---|---|---|
| double scalar db1 | refTest | ( netdoc.SampleMethods this, double scalar db1) |
Type:
obj = netdoc.SampleMethods; db4 = refTest(obj,6)
db4 =
12
To call a method using a params keyword, use the paramsTest method. The function signature is shown in the following table.
| Return Type | Name | Arguments |
|---|---|---|
| int32 scalar RetVal | paramsTest | ( netdoc.SampleMethods this, System.Int32[] num) |
Type:
obj = netdoc.SampleMethods; mat = [1, 2, 3, 4, 5, 6]; db5 = paramsTest(obj,mat)
db5 =
21
![]() | MATLAB Does Not Display Protected Properties or Fields | Call .NET Methods with Optional Arguments | ![]() |

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 |