Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2007

Tip: Looking for answers? Try searching our database.

Passing a managed object from C# to CLI by reference

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DaTurk - 07 Jun 2007 19:55 GMT
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?
Tamas Demjen - 07 Jun 2007 20:30 GMT
> 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
William DePalo [MVP VC++] - 07 Jun 2007 20:33 GMT
> 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
Ben Voigt [C++ MVP] - 07 Jun 2007 20:50 GMT
> 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.
DaTurk - 07 Jun 2007 21:07 GMT
> > 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
[quoted text clipped - 8 lines]
>
> in the argument list.

THank you, that was alot of help.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.