今天,當我看到創建的靜態辭典並對其進行初始化ç#代碼:初始化靜態字典在C++/CLI創造
public static readonly Dictionary<string, string> dict = new Dictionary<string, string>()
{
{"br","value1"},
{"cn","value2"},
{"de","value3"},
};
,但是當我決定寫C++/CLI相同的代碼,發生了錯誤。這裏是我的嘗試:
static System::Collections::Generic::Dictionary<System::String^, System::String^>^ dict = gcnew System::Collections::Generic::Dictionary<System::String^, System::String^>()
{
{"br","value1"},
{"cn","value2"},
{"de","value3"},
};
我能做到這一點,如果是的話,怎麼樣?
可能的[C++ CLI集合初始值設定語法]的副本(http://stackoverflow.com/questions/1923928/c-cli-collection-initializer-syntax) – 2011-05-16 18:13:58