有沒有一種「LINQ」方式來做到這一點?是否有從鍵/值對列表轉到字典的LINQ方法?
var array = new string[] { "BASE TABLE", "Table", "VIEW", "View" };
var list = array.ToList();
var dictionary = new Dictionary<string, string>();
for (int i = 0; i < list.Count; i += 2)
{
dictionary[list[i]] = list[i + 1];
}
不錯,謝謝 – 2012-02-09 00:52:48