title: How to convert CIDR subnet mask to HEX format?
body: <p>Tell me how to get a value equal to <code>FFFFFFFE</code> it turns out to output only <code>EFFFF</code> in reverse order and without the first two characters of <code>FF</code></p>
  
  <p>Source Code: <a href="https://stackoverflow.com/a/3152101/7549532">Converting subnet mask “/” notation to Cisco 0.0.0.0 standard</a></p>
  
  <pre><code>var cidr = 23;
  var zeroBits = 32 - cidr;
  var result = uint.MaxValue;
  
  result &amp;= (uint)((((ulong)0x1 &lt;&lt; cidr) - 1) &lt;&lt; zeroBits);
  result = (uint)IPAddress.HostToNetworkOrder((int)result);
  
  textBoxHex.Text = result.ToString("X");
  </code></pre>