Is this supported in C++ CLI? I want to do something like the following C# example in C++ CLI
var dictionary = new Dictionary<string, string> { { "foo", "bar" } };
Thanks
Is this supported in C++ CLI? I want to do something like the following C# example in C++ CLI
var dictionary = new Dictionary<string, string> { { "foo", "bar" } };
Thanks
The best I came up with was creating an array initialized inline, then initializing the dictionary with the contents of the array in a static constructor. Something like
static initonly System::Collections::Generic::Dictionary<System::String^, System::String^>^ dictionary;
static initonly array<System::String^> arrayToPopulateDictionary = gcnew array<System::String^> { "foo", "bar" };
static Foo()
{
for (int i = 0; i < arrayToPopulateDictionary->Length; i += 2)
listMappings->Add(arrayToPopulateDictionary[i], arrayToPopulateDictionary[i + 1]));
}