Reputation: 12755
I have an IList which contains a custom type. One of the properties of that custom type is called ID. How could I convert that without using a for loop? The array should not be of the CustomType, but if the type of ID, which is int.
Thanks!
Upvotes: 2
Views: 2200
Reputation: 29186
Try:
sourceList.Select(i => i.ID).ToArray();
Where sourceList
is your list of type IList<CustomType>.
Upvotes: 14