title: What is the LINQ way to select x and y from same z from a List of 3D Vector?
body: <p>I have some 3D data inside a list:</p>
  
  <pre><code>myDataList[0] - { X: 164 , Y: 79 , Z: 120 }
  myDataList[1] - { X: 146 , Y: 63 , Z: 120 }
  myDataList[2] - { X: 192 , Y: 59 , Z: 120 }
  myDataList[3] - { X: 196 , Y: 59 , Z: 120 }
  myDataList[4] - { X: 110 , Y: 55 , Z: 120 }
  myDataList[5] - { X: 148 , Y: 69 , Z: 122 }
  myDataList[6] - { X: 194 , Y: 59 , Z: 122 }
  myDataList[7] - { X:  18 , Y: 47 , Z: 122 }
  </code></pre>
  
  <p>I want to get the X and Y coordinate based on the same Z coordinate</p>
  
  <p>I am trying to do this in LINQ way with a loop.</p>
  
  <pre><code>for (int i = 0; i &lt; myDataList.Count; i++)
  {
      myXList = myDataList.Where(x =&gt; myDataList[i].Z == myDataList[i + 1]).Select(x =&gt; x.X).ToList();
  
      myYList = myDataList.Where(y =&gt; myDataList[i].Z == myDataList[i + 1]).Select(y =&gt; y.Y).ToList();
  }
  </code></pre>
  
  <p>But my problem now is how to distinct the same Z from the list and select the X and Y. The above <code>for</code> loop is wrong because it is only checking the the distinct Z for <code>i</code> and <code>i + 1</code> But not all the i at once. </p>
  
  <p>Any helping hand?</p>