title: Code Golf: C#: Convert ulong to Hex String
body: <p>I tried writing an extension method to take in a ulong and return a string that represents the provided value in hexadecimal format with no leading zeros.  I wasn't really happy with what I came up with... is there not a better way to do this using standard .NET libraries?</p>
  
  <pre><code>public static string ToHexString(this ulong ouid)
  {
      string temp = BitConverter.ToString(BitConverter.GetBytes(ouid).Reverse().ToArray()).Replace("-", "");
  
      while (temp.Substring(0, 1) == "0")
      {
          temp = temp.Substring(1);
      }
  
      return "0x" + temp;
  }
  </code></pre>