Csharp/CSharp Tutorial/Data Type/Hexadecimal
Example of a Hexadecimal Format Specifier
class MainClass
{
static void Main()
{
// Displays "0x2A"
System.Console.WriteLine("0x{0:X}", 42);
}
}
Hexadecimal Literal Value
class MainClass
{
static void Main()
{
// Display the value 42 using a hexadecimal literal.
System.Console.WriteLine(0x002A);
}
}
Numeric Formatting: Hexadecimal ({0:X}, {0:x8})
A hexadecimal literal must begin with 0x (a zero followed by an x).
using System;
class MainClass
{
public static void Main()
{
Console.WriteLine("{0:X}", 255);
Console.WriteLine("{0:x8}", 1456);
}
}
FF 000005b0