public class Person
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
}
I have a list :
List<Person> list = new List<Person>();
I'd like get, the Id value of all entries of the list with comma separator, like this : id1, id2, id3
Use string.Join to join values and Enumerable.Select to selected desired values:
string allIds = string.Join(", ", list.Select(i => i.Id.ToString()));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With