Format an decimal int to to Hexadecimal with ("X") Format Specifier in CSharp
Description
The following code shows how to format an decimal int to to Hexadecimal with ("X") Format Specifier.
Example
using System;/*from w w w . java 2s . c om*/
public class MainClass {
static void Main()
{
int value = 12345;
Console.WriteLine(value.ToString("x"));
Console.WriteLine(value.ToString("X"));
Console.WriteLine(value.ToString("X8"));
value = 123456789;
Console.WriteLine(value.ToString("X"));
Console.WriteLine(value.ToString("X2"));
}
}
The code above generates the following result.