Reputation: 626
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!
Upvotes: 1
Views: 122
Reputation: 40346
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#.
Upvotes: 1