public class MyBindingList : BindingList<int>
{
public MyBindingList()
{
}
private BindingList<int> temp;
public void Backup()
{
int[] arr = new int[this.Count];
this.CopyTo(arr,0);
temp = new BindingList<int>(arr);
}
public void Restore()
{
this.Items.Clear();
//for(int i=0;i<temp.Count;i++) this.Add(temp[i]);
}
}
//for(int i=0;i<temp.Count;i++) this.Add(temp[i]);
is a so slowly way to restore, so what can i use for more efficiently restore()?
With your example, foreach is the easiest and quickest way.
The faster way is via a copy-contructor. However with your example, it won't work. You can't say this = new ...
Edit: Side-comment, you can clean up Backup() by deleting the creation of the array and just call: