Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
C# Program to write a number in hexadecimal format
Let’s say the following is the number −
int a = 12250;
You can work around the following ways to get a number in hexadecimal format −
{0:x}
{0:x8}
{0:X}
{0:X8}
Here is the code −
Example
using System;
class Demo {
static void Main() {
int a = 12250;
Console.WriteLine("{0:x}", a);
Console.WriteLine("{0:x8}", a);
Console.WriteLine("{0:X}", a);
Console.WriteLine("{0:X8}", a);
}
}
Output
2fda 00002fda 2FDA 00002FDA
Advertisements
