Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Converting between number bases in C#

views
     
TSnazo
post Mar 3 2006, 10:08 AM, updated 20y ago

Getting Started
**
Junior Member
107 posts

Joined: Nov 2005
From: Kât Lởng Po


Does the .NET framework provide any way to convert between number bases? Let`s say from decimal to hex. I`ve tried searching MSDN. Can`t find anything ther. Guess i have to write my own code for that...
tcs
post Mar 3 2006, 11:06 AM

He's so good i just can't think of a caption
*******
Senior Member
4,637 posts

Joined: Jan 2003
From: Where i come from?



Google is yr best fren smile.gif

Have u try at this method : Convert.ToString(value,base) method?
anthony_yio
post Mar 3 2006, 11:22 AM

........
Group Icon
Elite
1,828 posts

Joined: Jan 2003


QUOTE(nazo @ Mar 3 2006, 10:08 AM)
Does the .NET framework provide any way to convert between number bases? Let`s say from decimal to hex. I`ve tried searching MSDN. Can`t find anything ther. Guess i have to write my own code for that...
*
All the number in the computer are stored as binary. So, internally it is all converted to dec or hex for display.

I assume you mean to display the number in hex in string?


IN Microsoft.VisualBasic.dll

Public Shared Function Oct( _
ByVal Number As { Byte | Short | Integer | Long | Object } _
) As String

Public Shared Function Hex( _
ByVal Number As { Byte | Short | Integer | Long | Object } _
) As String

or you can just use System.String.Format, adjust the format specifier.

 

Change to:
| Lo-Fi Version
0.0115sec    0.32    5 queries    GZIP Disabled
Time is now: 24th December 2025 - 07:34 AM