如何將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