title: Selecting items from generic list based on true condition from another list
body: <p>I am wondering if there would be any LINQ/Lambda expression solution for the problem below.</p>
  
  <p>I have 2 generic lists</p>
  
  <h1>List 1</h1>
  
  <pre><code>public class Data
  {
    public string ID { get; set;}
    public string Package { get; set;}
  }
  
  List&lt;Data&gt; listData = new List&lt;Data&gt;();
  
  Data data1 =  new Data { ID = "1", Package = "Test" };
  Data data2 =  new Data { ID = "2", Package = "Test2" };
  Data data3 =  new Data { ID = "3", Package = "Test2" };
  Data data4 =  new Data { ID = "4", Package = "Test4" };
  
  listData.Add(data1);
  listData.Add(data2);
  listData.Add(data3);
  listData.Add(data4);
  </code></pre>
  
  <h1>List 2</h1>
  
  <pre><code>List&lt;int&gt; listFilter =  List&lt;int&gt;();
  
  listFilter.Add(1);
  listFilter.Add(0);
  listFilter.Add(0);
  listFilter.Add(1);
  </code></pre>
  
  <p>I would like to filter "listData" based on the true (1) criteria from "listFilter". For the above example, I must be able to pull data1 and data4 into a new list.</p>
  
  <p>At the moment, I am using a for loop to achieve this as below.</p>
  
  <pre><code>List&lt;Data&gt; listResult =  new List&lt;Data&gt;();
  for(int index=0; index&lt;listData.Count; index++)
  {
      if(listFilter[index]==1)
      {
         listResult.Add(listData[index]);
      }
  
  }
  </code></pre>
  
  <p>I would appreciate if someone could show me to use LINQ or Lambda expression to achieve this.</p>
  
  <p>Thanks</p>
  
  <p>Balan</p>