跳到主要內容

發表文章

目前顯示的是有「collection」標籤的文章

在 C# 中有無類似jAVA map 的資料結構

在 C# 中有無類似jAVA map 的資料結構 答案是 >>>> Dictionary 賦值             Dictionary < string , string []> dic = new Dictionary < string , string []>();             dic.Add( "cookie" , new string []{ "Free cookie" , "cookie" });             dic.Add( "drink" ,  new string [] { "Free drink" , "drink" }); 取值 foreach ( KeyValuePair < int , string []> item in dic ){               System. Console .WriteLine(" key: "+ item.key );        System. Console .WriteLine("Value: "+ item.value[0] );      } 結果:             key: cookie  value: Free cookie key: drink value: Free drink Note: 每組key 必須唯一