title: Round integer to nearest high number in array
body: <p>I have an array of ints like this: [32,128,1024,2048,4096]</p>
  
  <p>Given a specific value, I need to get the closest value in the array that is equal to, or higher than, the value.</p>
  
  <p>I have the following code</p>
  
  <pre><code>  private int GetNextValidSize(int size, int[] validSizes)
    {
  
        int returnValue = size;
  
        for (int i = 0; i &lt; validSizes.Length; i++)
        {
            if (validSizes[i] &gt;= size)
            {
                returnValue = validSizes[i];
                break;
            }
        }
  
        return returnValue;
    }
  </code></pre>
  
  <p>It works, but is there any better/faster way to do it? The array will never contain more than 5-10 elements.</p>
  
  <p><strong>Clarification:</strong> I actually want to return the original value/size if it is bigger than any of the valid sizes. The validSizes array can be considered to always be sorted, and it will always contain at least one value.</p>