Question: This should be very simple but I searched and couldn't find a similar linq example. 

I have a function below.

```
viewModel.SLGDeptSalesList = viewModel.SLGDeptSalesList.Where(
    (value, index) => index == 0).ToList();

```

It returns an index within the sales list. 

I need to customize it to return multiple hard coded index's such as 1,3,4,6. 

How can I use linq to do this in one line? 

Thanks a bunch!

Answer: 
You could use `Contains` on an array:

```
var indices = new [] {1, 3, 4, 6};
viewModel.SLGDeptSalesList = viewModel.SLGDeptSalesList.Where(
  (value, index) => indices.Contains(index)).ToList();

```

Using `Contains` on an array is a common technique when you have queries you want to execute on SQL (not in your case, but in general), e.g. <https://blogs.msdn.microsoft.com/alexj/2009/03/25/tip-8-how-to-write-where-in-style-queries-using-linq-to-entities/>
If your indexes are hardcoded in a list then you can just use the .Exists() within your Where. but if they are just 

```
   var indices = new List<int>(){1,3,4,6};
   viewModel.SLGDeptSalesList = viewModel.SLGDeptSalesList.Where((value, index) => indices.Exists(index)).ToList();

```