zrmn5a
Last Updated: February 25, 2016
·
345
· aviatrix
B324968ed50da86db79396915ee5c7d5

Pre-initializing list/dictionaries gives speed improvement

Recently i found out that you gain around 50% speed improvement when adding items to a list/ dictionary if the list/dictionary was initialized before adding the item to it. This is very helpful in the cases where you know how many items the list is going to contain ( or at least approximately )

var list = new List<T>(1000);
Say Thanks
Respond