如何將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. convert <vector><string> TO <vector><int> C++,Win32
- 3. convert IQueryable <int> to <int>
- 4. C#List <dictionary> To Json
- 5. List <int> to IEnumerable <IComparable>
- 6. List <T> to string []
- 7. Convert System.Collections.GenericList'1 [Newtonsoft.Json.Linq.JToken] List to Json Array c#
- 8. Serialize List <ICustomClass> to xml?
- 9. List <T> to DataView
- 10. DataTable to List <T> conversion
- 11. convert type「system collection generic.iList <long> to long []」
- 12. Linq To Entities Compare List Against List <int>
- 13. Java 8 Lambda List to Map <Int,List <String>>
- 14. Can not cast list <object> to list <custom object>
- 15. 演員表<Object> to List <Map <String,Object >>
- 16. Simply IEnumerable <int> to List <KeyValuePair <int, int>>?
- 17. Casting C#List <>
- 18. Convert map to get size of list in each element
- 19. python convert list [0,1,2,3,4,5] to [0,1,2],[1,2,3],[2,3,4]
- 20. Android HTTPPost List <NameValuePair> post to php?
- 21. C#6.0 to <6.0
- 22. WPF ObservableCollection <T> vs BindingList <T>
- 23. Java - List to HashMap <Long,Set <String>>
- 24. Convert ArrayList <double[][]> double [] []
- 25. List <> .Tag值在C#
- 26. C#List <> GroupBy 2 Values
- 27. C#List <string>「contains」question
- 28. c#List <Class> Additions
- 29. CONVERT HEADER INTO <img>
- 30. IDictionary <String,List <OpenXmlCompositeElement >> - 獲取List <OpenXmlCompositeElement>?
的BindingList實現IList接口。你確定你需要一個實際的'List'嗎? – Heinzi 2012-04-18 07:14:53