title: How to find next 2 or 4 null keys in dictionary with starting index
body: <p>I have <code>Dictionary&lt;ushort, ushort&gt;</code> and let's say I have <code>KeyValuePair</code> from json file with index <code>43001</code> and value. If the value is <code>float</code> I have to convert the float to 2 ushort values and store them in the dictionary where the higher order bytes will be at <code>43001</code> and the lower order bytes will be stored at <code>43002</code>. If it's <code>double</code> I have to store it as 4 ushorts. This is fine, I know how to do it. If I have another <code>float</code> value with the same starting index of <code>43001</code> I have to store it starting with <code>43003</code>. If <code>43001</code> is already present, how can I find next 2 available index (or 4 for double)  after <code>43001</code> till <code>65535</code>. </p>
  
  <p>I know I can do something like</p>
  
  <pre><code>for (ushort i = 43001; i &lt; 65535; i += 2)
  {
     if (!dict.ContainsKey(i) &amp;&amp; !dict.ConainsKey(i + 1))
     {
         return //whatever;
     }
  }
  </code></pre>
  
  <p>and the same for double, but I think there is more elegant and better way. </p>