using System.Collections.Generic;
public static void Main()
Program pg = new Program();
int ? [] req = new int ? []{2000, 3000};
var res = pg.GetData(req);
foreach (var item in res)
Console.WriteLine(item.itemId);
public List<ItemViewModel> GetData(int ? [] categoryIds)
List<int ? > catIds = categoryIds.ToList();
List<ItemViewModel> model = new List<ItemViewModel>();
model.Add(new ItemViewModel() { itemId = 0, itemName = "item 1 ", categoryId = 1000 });
model.Add(new ItemViewModel() { itemId = 2, itemName = "item 1 ", categoryId = 2000 });
model.Add(new ItemViewModel() { itemId = 3, itemName = "item 1 ", categoryId = 3000 });
model.Add(new ItemViewModel() { itemId = 4, itemName = "item 1 ", categoryId = 4000 });
return model.Where(i => catIds.Contains(i.categoryId.Value)).ToList();
public class ItemViewModel