- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Hexadecimal ("X") Format Specifier
The hexadecimal ("X") format specifier is used to convert a number to a string of hexadecimal digits.
Set the case of the format specifier for uppercase or lowercase characters to be worked on hexadecimal digits greater than 9.
Let us understand this with an example −
“X” for PQR, whereas “x” for pqr
Example
using System; using System.Numerics; using System.Globalization; class Demo { static void Main() { int num; num = 345672832; Console.WriteLine(num.ToString("X")); Console.WriteLine(num.ToString("X2")); num = 0x307e; Console.WriteLine(num.ToString("x")); Console.WriteLine(num.ToString("X")); } }
Output
149A8C80 149A8C80 307e 307E
- Related Articles
- C# Currency ("C") Format Specifier
- C# Exponential (“E”) Format Specifier
- C# Percent ("P") Format Specifier
- C# Numeric (“N”) Format Specifier
- C# Decimal ("D") Format Specifier
- C# Fixed-Point (“F”) Format Specifier
- Sortable ("s") Format Specifier in C#
- C# Round-trip ("R") Format Specifier
- Month ("M", "m") Format Specifier in C#
- Short Time ("t") Format Specifier in C#
- Long Time ("T") Format Specifier in C#
- Year Month ("Y") Format Specifier in C#
- Long Date ("D") Format Specifier in C#
- The "0" custom format specifier in C#
- C# General Date Short Time ("g") Format Specifier

Advertisements