Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert BindingList<MyObject> to List<MyObject> c#

Tags:

c#

bindinglist

How can I convert BindingList to List ?

like image 975
Dimitar Tsonev Avatar asked Apr 18 '12 07:04

Dimitar Tsonev


3 Answers

Try this

List<int> list = yourBindingList.ToList();

int is your type =)

like image 79
LuckSound Avatar answered Sep 24 '22 18:09

LuckSound


If you're using .NET 2.0, then this is the solution:

public List<T> ToList()
{
    return new List<T>(this); // this - is a BindingList compatible object
}
like image 27
Alexey Avatar answered Sep 24 '22 18:09

Alexey


List list = yourBindingList.Cast().ToList();

like image 38
TerryMa Avatar answered Sep 20 '22 18:09

TerryMa