我还有另一个托管 C++ KeyValuePair 问题,我知道在 C# 中做什么,但是很难转换为托管 C++。这是我想在 C# 中执行的代码:
KeyValuePair<String, String> KVP = new KeyValuePair<string, string>("this", "that");
我已经将它反映到 MC++ 中并得到了这个:
KeyValuePair<String __gc*, String __gc*> __gc* KVP = (S"this", S"that");
我要翻译成:
KeyValuePair<String ^, String ^> KVP = (gcnew String("this"), gcnew String("that"));
我从上一个问题中知道 KeyValuePair 是一种值类型;问题是它是 C++ 中的值类型和 C# 中的引用类型吗?谁能告诉我如何从 C++ 设置 KeyValuePair 的键和值?