C ++/CLI boxing/unboxing and ref/out issue

Source: Internet
Author: User
Tags dotnet

1. Boxing and unboxing in C ++/CLI

Int ^ HI = 123;
Int c = * Hi;
2. Use C # functions with ref/out arguments in C ++/CLI

If the argument is DOTNET value type, then directly create an instance of it on stack in C ++/CLI and pass it when calling the C # function;

If the argument is DOTNET ref type, then create a handle of that type and initialize it, and pass it.

More:

C ++/CLI uses C # module functions having arguments "Ref xx", "Out xx"
---- The C ++/CLI code
Void Foo (Bar ^ % x );
Transforms
Void Foo (ref Bar X );
--- The concept of out is for the most part limited to C #. the CLR really only sees ref parameters. The out concepts is achieved via a mod opt I believe and most limits ages ignore it.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.