1
任何人都可以幫助我如何快速處理大字典中的所有數據嗎?我認爲foreach循環是一個緩慢的方法。如何處理大字典中的所有數據
Dictionary<string, Student> dict = new Dictionary<string Student>();
foreach(var key in dict.keys) {
//do something with key
}
任何人都可以幫助我如何快速處理大字典中的所有數據嗎?我認爲foreach循環是一個緩慢的方法。如何處理大字典中的所有數據
Dictionary<string, Student> dict = new Dictionary<string Student>();
foreach(var key in dict.keys) {
//do something with key
}
如果你是真正的處理每一個項目,後續將讓你的鍵和值在一個鏡頭:
foreach (var kvp in dict)
{
// do something with kvp.Key?
// do something with kvp.Value?
}
如果異步操作會像Parallel.ForEach有用的東西可能是你需要的工具。
謝謝,你的回答非常好。我認爲Parallel.ForEach是我需要的。 –
可能重複[什麼是最有效的循環在C#](http://stackoverflow.com/questions/15247247/what-is-the-most-efficient-loop-in-c-sharp) – jacefarm