473,326 Members | 2,655 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,326 software developers and data experts.

mc++ and pass by reference

Greetings,

I am very new to the MC++ 2005 visual studio world, and I was wondering how
you do pass by reference under the .Net syntax of mc++

(ie:) To do it in the C# version you would do something like this.
void myFuncA(ref string myValue)
{
myValue = "test";
}

(ie:) I tried to do something similar in MC++, but it doesn't show up right
under
the C# applications.
void myFuncA(System::String^ & myValue)
{
myValue = "test";
}

When I do this it shows up in my C# client app as "myFuncA(string* myValue)"
when the intellisense is showing? Is there something else I can do?

Thanks in advance for any suggestions!

Nov 3 '06 #1
2 1230
I found the solution to my problem:

(ie:) Here is the C# version.
void myFuncA(ref string myValue)
{
myValue = "test";
}

(ie:) The solution on how to do this in MC++ is the following.
void myFuncA(System::String^% myValue)
{
myValue = "test";
}

Use the "%" symbol for the equivalent of the "ref" keyword within a C# and
mc++.

Nov 3 '06 #2

"BartMan" <Ma******@community.nospamwrote in message
news:1D**********************************@microsof t.com...
>I found the solution to my problem:

(ie:) Here is the C# version.
void myFuncA(ref string myValue)
{
myValue = "test";
}

(ie:) The solution on how to do this in MC++ is the following.
void myFuncA(System::String^% myValue)
{
myValue = "test";
}

Use the "%" symbol for the equivalent of the "ref" keyword within a C# and
mc++.
That's actually C++/CLI, which replaced Managed C++. Also % is a tracking
reference, which is like a native reference &, except that it can be updated
by the garbage collector. Your first try would have required that the
String be pinned first.

There's also an OutAttribute which you can tag onto a parameter along with %
to make the equivalent of C# "out" keyword.
>

Nov 3 '06 #3

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

Similar topics

3
by: Keith M | last post by:
Hi, I am a bit of a newcomer to C# but have experience with (unmanaged) C++. Now, I have a 3rd party dll and headers. This dll is a C++ style dll that exports classes and structs. I am...
3
by: Philip | last post by:
I am invoking a mc++ method from C# via an unsafe code block. The reason for the unsafe code block is that I am receiving a int as a return parameter. I am invoking the method with a "ref...
1
by: Alexander Arlievsky | last post by:
Hi, I have mixed mode dll, which contains files with managed objects written in MC++, and files with regular "C" functions. One of those functions receives function pointer as parameter. I want to...
2
by: Edward Diener | last post by:
In C++ an overridden virtual function in a derived class must have the exact same signature of the function which is overridden in the base class, except for the return type which may return a...
2
by: Lev | last post by:
Hi, I have some code that does reflection on an assembly I load. When I try to get the attributes on one of the methods implemented in the assembly, the MC++ version does not return anything....
12
by: abintom | last post by:
hi, i am writing a dll in MC++ for using from C#. For the dll function say 'TestFunc', i need to get a SortedList<string,stringas an argument. I am not very clear about using SortedList in...
8
by: WebSnozz | last post by:
I have an application written in C that does a lot of low level stuff. It does a lot of things like casting from void*'s. I want to create a new GUI for it in either C# or MC++, but reuse the...
3
by: Bruno LIVERNAIS | last post by:
Hi, We are currently installing a DB2 V9 ESE on a Linux server (RHEL4U4-x86_64). Installation runs successfully on each node. Database user environment is OK and the instance is well created. To...
4
by: =?Utf-8?B?QmlsbCBTcGFobg==?= | last post by:
I have an abstract base class defined in an MC++ class library. I then create a descendent class in a C# class library. This seems to work OK with the exception of one of the abstract member...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.