What is the easiest and fastest way to convert an array to BindingList?
how to convert array to BindingList
7k views Asked by Okan Kocyigit At
4
There are 4 answers
0
On
Be careful when using the BindingList(IList ..) constructor with an Array as the IList will be read-only.
Any attempts to add/remove from the BindingList will therefore throw a NotSupportedException as the IList can't handle the functionality as the Collection is read-only.
To create an editable BindingList you'll have to convert it to a list before using the IList constructor.
A nice description as to why Arrays are built from IList can be found here for some additional reading: Why array implements IList?
Use the
BindingList
constructor that takes anIList<T>
.