List<Customer> c= new List<Customer>()
{
new Customer{Id = 1, Name = "Bruce"},
new Customer{Id = 2, Name = "John"}
};
I just know
c.ForEach(o => str += o.Id.ToString() + ",");
Any ways to make it simple?
I just wanna get Id out and make Ids array int[] Ids = new {Id = 1, Id = 2}
If you want to create an array with all those ids then you can use Select and ToArray methods :
int[] ids = c.Select(i => i.Id).ToArray();
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