I have a function which parses one string into two strings. In C# I would declare it like this:
void ParseQuery(string toParse, out string search, out string sort)
{
...
}
and I'd call it like this:
string searchOutput, sortOutput;
ParseQuery(userInput, out searchOutput, out sortOutput);
The current project has to be done in C++/CLI. I've tried
using System::Runtime::InteropServices;
...
void ParseQuery(String ^ toParse, [Out] String^ search, [Out] String^ sort)
{
...
}
but if I call it like this:
String ^ searchOutput, ^ sortOutput;
ParseQuery(userInput, [Out] searchOutput, [Out] sortOutput);
I get a compiler error, and if I call it like this:
String ^ searchOutput, ^ sortOutput;
ParseQuery(userInput, searchOutput, sortOutput);
then I get an error at runtime. How should I declare and call my function?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…