I have an object, with ID and Name properties.
I have a list of the objects, but I want to convert it to a list of strings containing the name of the object.
I’m guessing there’s some fancy Linq method that will put the name of the object into the list.
List<string> myObjectNames = myObjectList.?
If you know it is specifically a
List<T>and not another collection type then you can useList<T>.ConvertAll:Example:
If you just know that it is an enumerable type but not necessarily a list then you can use the LINQ extension methods
Enumerable<T>.SelectandEnumerable<T>.ToList: