如何轉換String[]
到IDictionary<String, String>
?如何將String []轉換爲IDictionary <String,String>?
在指標0,2,4的值,......應鍵,因此在值的指數1,3,5,......應值。
例子:
new[] { "^BI", "connectORCL", "^CR", "connectCR" }
=>
new Dictionary<String, String> {{"^BI", "connectORCL"}, {"^CR", "connectCR"}};
這是類似的,但不是一個副本:http://stackoverflow.com/questions/1624341/getting-pair-set-using-linq – cfeduke 2011-01-12 15:10:49
和http://stackoverflow.com/questions/4461367/linq-to-objects-return-pairs-of-numbers-from-list-of-numbers – cfeduke 2011-01-12 15:11:45
如果你需要這麼多次,我建議你將你最喜歡的答案提取到一個擴展方法`IDictionary ToDictionary(這個字符串[] arr)` –
HuBeZa
2011-01-12 15:18:32