title: c# finding all private IP addresses between 172.16 and 172.31
body: <p>I am trying to find if an IP address is within 172.16.0.0 and 172.31.255.255 (Class B) IPs. If it is, consider this to be a private address and therefore do something with it. But I can't be certain what I have done is correct. The code I have done to try to achieve this : </p>
  
  <pre><code> // The requested IP
   System.Net.IPAddress IP = System.Net.Dns.GetHostAddresses(uri)[0];
  
   // Get the long values of the two IPs in question
   long startIP = System.Net.IPAddress.Parse("172.16").Address;
   long EndIP = System.Net.IPAddress.Parse("172.31").Address;
  
   if (IP.Address &gt;= startIP &amp;&amp; IP.Address &lt;= EndIP)
   {
      // OK the requested domain is an internal one so lets return this..
      return true
   }
  </code></pre>
  
  <p>I can't really test this as I don't have a 172. domain. So I hope you can understand why I've asked this. </p>
  
  <p>Thanks </p>