How to convert an integer to fixed length hex string in C#?
<p>I have an integer variable with max value of 9999.</p>

<p>I can convert to fixed length string (4-characters):</p>

<pre><code>value.ToString("0000");
</code></pre>

<p>and I can convert it to hex:</p>

<pre><code>value.ToString("X");
</code></pre>

<p>I want to convert it to a hex string of four characters (padded with 0 at the left if the value is converted to less than four digits hex value). I tried the following which didn't work.</p>

<pre><code>value.ToString("0000:X");
</code></pre>

<p>OK, I can check the length of hex string and pad left with zeros.</p>

<p>But is there any straightforward way?</p>
