المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : how to simplify the loop?



C# Programming
08-24-2011, 05:13 PM
Hi
I have following loop. With one of the workflow, rangeDataMappingsToClear gets 100,000 records and rangeKeyMappings gets 10,000 records. This is taking long time hence application hangs.

How to simplify this loop?


List rangeDataMappingsToClear= new List();Dictionary rangeDataMappings = new Dictionary();Dictionary rangeKeyMappings = new Dictionary(); foreach (string key in rangeDataMappingsToClear) { rangeDataMappings.Remove(key); foreach (List formulaKeys in rangeKeyMappings.Values) { while (formulaKeys.Remove(key)) { } } } rangeDataMappingsToClear.Clear();