I have a custom BindingList for which I want to create my own AddRange method for.
public class MyBindingList<I> : BindingList<I>
{
...
public void AddRange(IEnumerable<I> vals)
{
foreach (I v in vals)
Add(v);
}
}
My problem with this is that performance is terrible with large collections. The case that I am debugging now is trying to add about 30,000 entries and take an invalid amount of time.
After exploring this problem on the Internet, it seems that the problem is that use is Addresizing the array with each addition. This answer I believe is:
If you use Add, it gradually resizes the internal array (doubles)
AddRange, , BindingList, , ?