如何将BindingList转换为List?Convert BindingList <MyObject> to List <MyObject> c#
8
A
回答
12
试试这个
List<int> list = yourBindingList.ToList();
int是你喜欢的类型=)
+0
我没有看到ToList()或Cast()方法与我的BindingList或MSDN中。这是一个不同的BindingList比System.ComponentModel.BindingList
+2
@RichShealer - 有点晚,但你需要确保你添加使用System.Linq; ToList()是一个扩展方法。 – CathalMF 2015-06-16 12:26:52
2
名单列表= yourBindingList.Cast()ToList()。
1
如果您使用.NET 2.0,那么这是解决方案:
public List<T> ToList()
{
return new List<T>(this); // this - is a BindingList compatible object
}
相关问题
- 1. Convert List <Object> to ByteArray
- 2. C#List <string> [] to Datatable
- 3. convert <vector><string> TO <vector><int> C++,Win32
- 4. convert ArrayList <Object[]> to Object []
- 5. convert IQueryable <int> to <int>
- 6. C#List <dictionary> To Json
- 7. List <int> to IEnumerable <IComparable>
- 8. LINQ:How to convert from ISingleResult <T> to IQueryable <int>
- 9. List <T> to string []
- 10. Convert System.Collections.GenericList'1 [Newtonsoft.Json.Linq.JToken] List to Json Array c#
- 11. python list convert to a table
- 12. Cast String to List <NameValuePair>
- 13. DataTable to List <T> conversion
- 14. List <T> to DataView
- 15. Serialize List <ICustomClass> to xml?
- 16. int [] [] convert --to - > Vector <Vector <Double>>
- 17. convert type“system collection generic.iList <long> to long []”
- 18. Linq To Entities Compare List Against List <int>
- 19. Can not cast list <object> to list <custom object>
- 20. Casting List <Concrete> to List <InheritedInterface> without .ToList()复制操作
- 21. Java 8 Lambda List to Map <Int,List <String>>
- 22. Simply IEnumerable <int> to List <KeyValuePair <int, int>>?
- 23. 演员表<Object> to List <Map <String,Object >>
- 24. Casting C#List <>
- 25. c#convert system.IO.Stream to Byte []
- 26. python convert list [0,1,2,3,4,5] to [0,1,2],[1,2,3],[2,3,4]
- 27. Convert map to get size of list in each element
- 28. List <Objects> to Json文件
- 29. Android HTTPPost List <NameValuePair> post to php?
- 30. C#6.0 to <6.0
的BindingList实现IList接口。你确定你需要一个实际的'List'吗? – Heinzi 2012-04-18 07:14:53