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

Passing a managed object from C# to CLI by reference

This might be a stupid question, but I want to do the equivalent of
passinf an arguement via the "out" keyword in C#, But in CLI. SO I
basically want to pass a managed object from c# into a CLI layer, make
changes to the object in the CLI layer, and have them reflected in the
c# layer. Could someone please show me the syntax to do this?

Jun 7 '07 #1
4 5384
DaTurk wrote:
I want to do the equivalent of
passinf an arguement via the "out" keyword in C#, But in CLI.
In C++/CLI, you can try this:

void foo([System::Runtime::InteropServices::Out] int% value)

which is equalivalent to the following in C#:

public void foo(out int value)

Another example, this time with a ref class:

void foo([System::Runtime::InteropServices::Out] String^% value)
//C++
public void foo(out string value)
//C#

Tom
Jun 7 '07 #2
"DaTurk" <mm******@hotmail.comwrote in message
news:11*********************@q66g2000hsg.googlegro ups.com...
This might be a stupid question, but I want to do the equivalent of
passinf an arguement via the "out" keyword in C#, But in CLI. SO I
basically want to pass a managed object from c# into a CLI layer, make
changes to the object in the CLI layer, and have them reflected in the
c# layer. Could someone please show me the syntax to do this?
Take a look at this page belonging to my friend Tomas Restrepo:

http://www.winterdom.com/cppclifaq/archives/000421.html

Regards,
Will
Jun 7 '07 #3

"DaTurk" <mm******@hotmail.comwrote in message
news:11*********************@q66g2000hsg.googlegro ups.com...
This might be a stupid question, but I want to do the equivalent of
passinf an arguement via the "out" keyword in C#, But in CLI. SO I
basically want to pass a managed object from c# into a CLI layer, make
changes to the object in the CLI layer, and have them reflected in the
c# layer. Could someone please show me the syntax to do this?
That doesn't sound like an out parameter at all, it sounds like passing a
managed handle to the C++/CLI code, for which you would use

'MyClass^ paramname'

in the argument list.
Jun 7 '07 #4
On Jun 7, 2:50 pm, "Ben Voigt [C++ MVP]" <r...@nospam.nospamwrote:
"DaTurk" <mmagd...@hotmail.comwrote in message

news:11*********************@q66g2000hsg.googlegro ups.com...
This might be a stupid question, but I want to do the equivalent of
passinf an arguement via the "out" keyword in C#, But in CLI. SO I
basically want to pass a managed object from c# into a CLI layer, make
changes to the object in the CLI layer, and have them reflected in the
c# layer. Could someone please show me the syntax to do this?

That doesn't sound like an out parameter at all, it sounds like passing a
managed handle to the C++/CLI code, for which you would use

'MyClass^ paramname'

in the argument list.
THank you, that was alot of help.

Jun 7 '07 #5

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

Similar topics

5
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a...
1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
1
by: Steven Blair | last post by:
Hi, I am having problem passing a string by reference to some C++ code. Wondered if anyone could help me out. C# code: myFunc(str);
2
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
2
by: Sasha Nikolic | last post by:
I have one unmanaged and one managed class in the same vc++ project. Managed object creates one instance of unmanaged class and needs to pass a callback reference so that unmanaged class can...
6
by: MSDNAndi | last post by:
Hi, I get the following warning: "Possibly incorrect assignment to local 'oLockObject' which is the argument to a using or lock statement. The Dispose call or unlocking will happen on the...
8
by: Notre Poubelle | last post by:
Hello, I have some legacy unmanaged C++ code in which I've introduced some managed C++ using the new CLI feature of VS 2005. My managed C++ code invokes a number of methods on a new C#class...
17
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.