CLI Reference Parameter used for CSharp

  • Thread starter Thread starter Ed
  • Start date Start date
E

Ed

Hi, dear all,
Here are some questions when I was writing CLI code, which would be
used by C# Project.

1. Reference Parameter
If CLI method have % reference type parameter, which is ref class,
could C Sharp use it?

In CLI code:

ClassA::SetB(ClassB% classB);


In CSharp:

ClassA classA=new ClassA();
ClassB classB=new ClassB();

classA.SetB(ref classB);
// But the build was failed:
// error CS1501: No overload for method 'SetB' takes '2' arguments


So, how can I use this CLI method in CSharp project?
 
Not sure about the "2 arguments" message, but your CLI code should have a hat
in there if ClassB is a ref class:
e.g.,
ClassA::SetB(ClassB ^%classB);
--
David Anton
http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, and C++
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
 
David Anton said:
Not sure about the "2 arguments" message, but your CLI code should have a
hat
in there if ClassB is a ref class:
e.g.,
ClassA::SetB(ClassB ^%classB);

I think the original notation is also possible, C# will just ignore the
modopt() attribute.

I suggest using .NET Reflector to view the public API generated by the
compiler.
 
I think the original notation is also possible, C# will just ignore the
modopt() attribute.

I suggest using .NET Reflector to view the public API generated by the
compiler.

Thank you!
I will have a try. And if "the public API generated by the compiler."
means the assembly code generated by compiler?
If so, it seems more and more tricks should be searched from the
assembly code generated by compiler.
 
Thank you!
I will have a try. And if "the public API generated by the compiler."
means the assembly code generated by compiler?

..NET Reflector can show the signature of each method in any language,
including, for example, C#.
 
Back
Top