473,395 Members | 1,341 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,395 software developers and data experts.

frustrating parameter issue

Hello everyone,

My question is part C# and part C++. Please don't kill me for bringing C#
inhere :-) Also please don't kill me for asking a n00b question, I'm still
new to C++/CLI and C#.
I have an assembly written in C++/CLI with a public function:

int MyClass::MyFunction(String ^x) {
x = "zzz";
return 0;
};
I want to call this function from a C# app and show the changed contents of
variable

MyClass TheClass = new MyClass();
String w = "m";
TheClass.MyFunction(w);
MessageBox.Show(w);
When executing, the messagebox shows 'm', and I want it to show 'zzz'.

What am I doing wrong here???

Thanks for reading sofar.

Vince.
Feb 26 '07 #1
3 1084
>I want to call this function from a C# app and show the changed contents of
>variable
Vince,

You need to define the function parameter as a tracking reference -
see "% Tracking Reference" in MSDN.

Dave
Feb 26 '07 #2
int MyClass::MyFunction(String ^%x) {
x = "zzz";
return 0;
};

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Vinz" wrote:
Hello everyone,

My question is part C# and part C++. Please don't kill me for bringing C#
inhere :-) Also please don't kill me for asking a n00b question, I'm still
new to C++/CLI and C#.
I have an assembly written in C++/CLI with a public function:

int MyClass::MyFunction(String ^x) {
x = "zzz";
return 0;
};
I want to call this function from a C# app and show the changed contents of
variable

MyClass TheClass = new MyClass();
String w = "m";
TheClass.MyFunction(w);
MessageBox.Show(w);
When executing, the messagebox shows 'm', and I want it to show 'zzz'.

What am I doing wrong here???

Thanks for reading sofar.

Vince.
Feb 26 '07 #3
Thanks very much guys :-)

I tried to use the % before but that doesn't compile. ^% compiles though. I
had to also use ref x instead of just x in the C# call too btw.

Anyway, I got it working now, thanks a lot :-)

Vince.

"David Anton" <Da********@discussions.microsoft.comwrote in message
news:D3**********************************@microsof t.com...
int MyClass::MyFunction(String ^%x) {
x = "zzz";
return 0;
};

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"Vinz" wrote:
>Hello everyone,

My question is part C# and part C++. Please don't kill me for bringing C#
inhere :-) Also please don't kill me for asking a n00b question, I'm
still
new to C++/CLI and C#.
I have an assembly written in C++/CLI with a public function:

int MyClass::MyFunction(String ^x) {
x = "zzz";
return 0;
};
I want to call this function from a C# app and show the changed contents
of
variable

MyClass TheClass = new MyClass();
String w = "m";
TheClass.MyFunction(w);
MessageBox.Show(w);
When executing, the messagebox shows 'm', and I want it to show 'zzz'.

What am I doing wrong here???

Thanks for reading sofar.

Vince.

Feb 27 '07 #4

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

Similar topics

5
by: Brandolon Hill | last post by:
Hi, Is there a way to check and see if a parameter is defined in XSLT? I have many stylesheets that all have an <xsl:include> of the same stylesheet, "foo.xsl". Foo relies on several...
3
by: Phil IU Guy | last post by:
I am having 2 issues, both acting very randomly, and for the most part I dont get this message on most computers, but I have had a couple computers get either issue 1, or issue 2. Issue #1: I...
3
by: Loui Mercieca | last post by:
Hi, I have a very strange and frustrating error. I developed an application, tested it and it works fine. Then i deploy it to another machine ( no installation, direct file transfer ) but it...
1
by: sd | last post by:
QUESTION: How can my ASP page - which uses language="VBScript" - pass a "System.Collections.ArrayList" object - as a parameter - to a C# method in the middle-tier ??? ----- Is it possible at...
20
by: Brien King | last post by:
If I have a parameter that has an Object type (as opposed to something like a string), can I make that parameter a CONST? Right now, if you pass an object into a sub/function, that sub/function...
16
by: hzmonte | last post by:
Correct me if I am wrong, declaring formal parameters of functions as const, if they should not be/is not changed, has 2 benefits; 1. It tells the program that calls this function that the...
8
by: Alec MacLean | last post by:
Hi, I'm using the DAAB Ent Lib (Jan 2006) for .NET 2.0, with VS 2005 Pro. My project is a Web app project (using the WAP add in). Background: I'm creating a survey system for our company, for...
0
by: ngoodearl | last post by:
Hi, I have upsized an access db to a sequel 2000 db. The db is used to perform a series of calculations to get a result. The user inputs the required parameters into a form and the data entered is...
2
tpgames
by: tpgames | last post by:
Not a question. Just didn't know where to put this montage. So realtek gave me a exe that will create a dump. The device refused saying that it only works with realtek. Like Duh! So, I let the...
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:
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.