Getting list of values out of list of objects
Use as follows.
Categories.Select(c => c.Id).ToList();
||
List<int> list = new List<int>();
foreach (Category item in Categories)
{
list.Add(item.Id);
}
This expression gives you the list you want:
Categories.Select(c => c.Id).ToList();
Also, don't forget
using System.Linq;