in c#, let's suppose that i have a class like as follows..
public class anItem
{
public string name { get; set; }
public string surname { get; set; }
}
and i use a generic list with that object, like.
List<anItem> listof = new List<anItem>();
listof.Add(new anItem { name = "name 1", surname = "surname 1" });
listof.Add(new anItem { name = "name 2", surname = "surname 2" });
listof.Add(new anItem { name = "name 3", surname = "surname 3" });
listof.Add(new anItem { name = "name 4", surname = "surname 4" });
is it possible take all surname 's from listof generic list to a string array ?
string[] takenSurnames = // take just surnames from listof
yes i can get that with foreach or for loops. but i wonder if there's any lambda expression or something like that shorter ?
Thanks in advance..