Convert List<object> to List<int>
How to easily convert a list of objects to a list of primative types
If you have a generic List<object>
of class objects, and want to generate a list of primative type based on a single class property, use the following...
C#
var newList = myList.ConvertAll(x => x.myProp);
VB.Net
Dim newList As List(of Integer) = myList.ConvertAll(Function(x) x.myProp)
It is not necessary to cast the primative type.
Added 22/02/2023 12:10