- 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
Advertisements