ref and out in C++/CLI

前端 未结 2 583
孤独总比滥情好
孤独总比滥情好 2021-02-02 09:18

I know that the C++/CLI code

void foo(Bar^% x);

transforms into

Void foo(ref Bar x);

What is the C++/CLI cod

相关标签:
2条回答
  • 2021-02-02 09:22

    There is no such specific syntax in C++/CLI. I think you can get fairly close by adding the OutAttribute to modify the parameter. But I'm not sure that achieves the exact same semantics as C# out.

    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 languages ignore it.

    0 讨论(0)
  • 2021-02-02 09:29

    You can use the OutAttribute:

    using namespace System::Runtime::InteropServices;    
    void foo([Out] Bar^% x); 
    
    0 讨论(0)
提交回复
热议问题