How do I go about converting a reflection.propertyinfo[] to a generic.list<>?
C# convert reflection.propertyinfo to Generic.List<>
2.7k Views Asked by mattgcon At
5
There are 5 best solutions below
0

One of the List<T>
constructors accepts an IEnumerable<T>
as its argument (i.e., your PropertyInfo array):
var list = new List<PropertyInfo>( propInfoArray );
2

Use the extension method ToList()
available in the System.Linq
namespace:
var myProperties = propertyInfoArray.ToList();
0

All of the above are correct. But it should also be mentioned that, like List<T>
all .net arrays implement IList<T>
.
var IList<PropertyInfo> ilist = reflection.propertyinfo;
Since I know that, almost all my functions accept IList<T>
when I need a list-like collection, which I can use with traditional arrays and lists.