문제

I have a Managed C++ class (Very old legacy code) that I am busy abstracting. I need to build a C# interface to the class.

In the Managed C++ class I have the following:

property SomeClass^ SomeClass { SomeClass^ get(); }

In the interface class (C#) would the following be the correct declaration:

SomeClass someClass { get; }

I'm unsure how to handle the reference part (^), since C# doesn't seem to allow

ref SomeClass someClass { get; }

Would it be necessary to take into account that the Managed C++ function returns a reference, or would it be handled internally? Or am I just missing something completely.

Thanks!

도움이 되었습니까?

해결책

Yes

    SomeClass someClass { get; }

is correct. The caret doesn't mean "ref" in the C# sense, ref is spelled % in C++/CLI. Caret just means "managed pointer", a distinction that is automatically figured out by the syntax of C# based on the types involved.

A^ in C++/CLI will always be A in C#.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top