Code Golf: C#: Convert ulong to Hex String
The solution is actually really simple, instead of using all kinds of quirks to format a number into hex you can dig down into the NumberFormatInfo class.
The solution to your problem is as follows...
return string.Format("0x{0:X}", temp);
Though I wouldn't make an extension method for this use.
You can use string.format:
string.Format("0x{0:X4}",200);
Check String Formatting in C# for a more comprehensive "how-to" on formatting output.