title: Find adjacent/neighboring elements in a list of objects c#
body: <p>I have a list of objects. I have a value, that is not in the list, but would like to find the adjacent elements, where that value would fit. Basically the previous and next element,like if this value was part of the list.</p>
  
  <pre><code>    var previous = 0;
      var next = 0;
      decimal Value = 45M;
  
          List&lt;MileStone&gt; items = new List&lt;MileStone&gt;();
                  items.Add(new MileStone() { CheckPoint = 0, Distance = 15.4M});// i = 0
                  items.Add(new MileStone() { CheckPoint = 20, Distance = 24.8M});// i = 1
                  items.Add(new MileStone() { CheckPoint = 40, Distance = 39.7M});// i = 2
                  items.Add(new MileStone() { CheckPoint = 60, Distance = 59.3M});// i = 3
                  items.Add(new MileStone() { CheckPoint = 80, Distance = 80.1M});// i = 4
  </code></pre>
  
  <p>In this example the 'Value' = 45, so that would fit between items[2] and item[3].
  Desired outcome would be, a new list of the neighboring values:</p>
  
  <pre><code>List&lt;MileStone&gt; items2 = new List&lt;MileStone&gt;();
  items2.Add(items[2]);
  items2.Add(items[3]);
  </code></pre>
  
  <p>If 'Value' = 10 there should be only a one element in the items2 list, because there is no previous case.</p>
  
  <pre><code>List&lt;MileStone&gt; items2 = new List&lt;MileStone&gt;();
  items2.Add(items[0]);
  </code></pre>
  
  <p>I would like to find an elegant, and nice solution for this, using LINQ Lambda expression.</p>
  
  <p>I can find the indexes with a for loop, then add the desired elements to the items2 list, but would like to find a LINQ approach.</p>
  
  <p>Any idea is welcomed!
  Thanks!</p>