ParameterType.FullName returns "System.Boolean&" explain why

G

Guest

Hello,

I am using reflections to get Parameters and their types of a COM Interop
Assembly method. ParameterType.FullName returns "System.Boolean&" what's the
significance of & at the end?

Here's my code:
/* Project1.Class1Class has 1 method doA, second param is boolean type */
//Get Type from Assebly
Assembly asm = Assembly.Load("Interop.Project1");
//Create Type instance
Type asmT = asm.GetType("Project1.Class1Class");

//get Method Info and Parameter info
MethodInfo mInfo = asmT.GetMethod("doA");
ParameterInfo[] paramsInfo = mInfo.GetParameters();
//display type full name
MessageBox.Show(paramsInfo[1].ParameterType.FullName);
 
M

Mattias Sjögren

I am using reflections to get Parameters and their types of a COM Interop
Assembly method. ParameterType.FullName returns "System.Boolean&" what's the
significance of & at the end?

It indicates that it's a byref parameter (like if you use the ref or
out modifiers in C#). paramsInfo[1].ParameterType.IsByRef should be
true.


Mattias
 
R

rossum

Hello,

I am using reflections to get Parameters and their types of a COM Interop
Assembly method. ParameterType.FullName returns "System.Boolean&" what's the
significance of & at the end?

The COM Interop Assembly may have been written in C++. In C++ an "&"
at the end of a method parameter indicates a reference parameter. In
C# this would be "ref System.Boolean".

rossum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top