473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

CLI Reference Parameter used for CSharp

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?

Aug 8 '07 #1
4 2509
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
"Ed" wrote:
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?

Aug 9 '07 #2

"David Anton" <Da********@discussions.microsoft.comwrote in message
news:D6**********************************@microsof t.com...
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.
--
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
"Ed" wrote:
>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?


Aug 9 '07 #3
Ed
On 8 9 , 10 28 , "Ben Voigt [C++ MVP]" <r...@nospam.nospamwrote:
"David Anton" <DavidAn...@discussions.microsoft.comwrote in message

news:D6**********************************@microsof t.com...
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.
--
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
"Ed" wrote:
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?
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.
Aug 9 '07 #4
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#.
If so, it seems more and more tricks should be searched from the
assembly code generated by compiler.


Aug 9 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rafael Veronezi | last post by:
Just to fix, correct me if I am wrong... With reference types (objects), if I assign an object to another, the assignment will be the address of the object, and not a copy of it's contents right?...
5
by: Dan =o\) | last post by:
given this brief scenario, is this possible somehow? class A { public SomeMethod() { } }
13
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
12
by: acb | last post by:
Hi, I have a list of different objects in a <List> Structure. There is only one category of each kind of object. Current I have the following methods: public static Flag GetFlagObj() {...
5
by: Michael Russell | last post by:
Hi all, Using C#, I've created a simple wrapper class for using Excel. I have Office Pro 2003 installed on my devel machine. The wrapper class works great, reading and writing to/from Excel. ...
3
by: jbaldi | last post by:
I am trying to pass an object as a reference parameter in a constructor. I would like my class with the reference parameter constructor to be able to change the value of that object from one of...
13
by: Francois Appert | last post by:
This post was originally in the C# Corner site, but their server is down. I'd like to see if this group can answer. I program in C++ and am learning C#. The issue is: why should anybody...
4
by: Everton Berz | last post by:
Hi, In the follow program I would like to have the parameter "c" in method "doSomething" as a value parameter, but it's running as a reference parameter. Why? How can I get parameter "c" as a...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.