469,323 Members | 1,551 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

C# Hexadecimal conversion

Hi,

I want to WriteLine a number in hexadecimal ( e.g. %x ), how would I do that
in C#?
--
Nadav
http://www.ddevel.com
Nov 16 '05 #1
3 22084
Use the ToString() method with the correct format specifier.
int x = 10;
Console.WriteLine(x.ToString("x"));

Nov 16 '05 #2
int nNum = 15;
Console.WriteLine ("Hex: {0:X}", nNum); // F
Console.WriteLine ("Hex: {0:x}", nNum); // f

X produces upper case hex, x produces lower case hex.
"Nadav" <Na***@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
Hi,

I want to WriteLine a number in hexadecimal ( e.g. %x ), how would I do
that
in C#?
--
Nadav
http://www.ddevel.com

Nov 16 '05 #3

int nNum = 15;
Console.WriteLine ("Hex: {0:X}", nNum); // F
Console.WriteLine ("Hex: {0:x}", nNum); // f

X produces upper case hex, x produces lower case hex.


I'm a beginner, so pardon the simplicity of what I am about to ask...

Using this same goal, how would you make a form to input a word and have it
converted to hex and displayed in a label once a button is pressed?

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Mike Jeffers | last post: by
10 posts views Thread by pavithra.eswaran | last post: by
5 posts views Thread by Damon | last post: by
2 posts views Thread by akash deep batra | last post: by
8 posts views Thread by Vijay | last post: by
7 posts views Thread by elliotng.ee | last post: by
6 posts views Thread by Andrea | last post: by
6 posts views Thread by sweeet_addiction16 | last post: by
11 posts views Thread by =?Utf-8?B?VHJlY2l1cw==?= | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.