title: Efficiently find nearest dictionary key
body: <p>I have a bunch of pairs of dates and monetary values in a <code>SortedDictionary&lt;DateTime, decimal&gt;</code>, corresponding to loan balances calculated into the future at contract-defined compounding dates. Is there an efficient way to find a date key that is nearest to a given value? (Specifically, the nearest key <em>less than or equal to</em> the target). The point is to store only the data at the points when the value changed, but efficiently answer the question "what was the balance on x date?" for any date in range.</p>
  
  <p>A similar question was asked ( <a href="https://stackoverflow.com/questions/1690929/what-net-dictionary-supports-a-find-nearest-key-operation">What .NET dictionary supports a &quot;find nearest key&quot; operation?</a> ) and the answer was "no" at the time, at least from the people who responded, but that was almost 3 years ago. </p>
  
  <p>The question <a href="https://stackoverflow.com/questions/5301164/how-to-find-point-between-two-keys-in-sorted-dictionary">How to find point between two keys in sorted dictionary</a> presents the obvious solution of naively iterating through all keys. I am wondering if any built-in framework function exists to take advantage of the fact that the keys are already indexed and sorted in memory -- or alternatively a built-in Framework collection class that would lend itself better to this kind of query.</p>