Atlanta Custom Software Development 

   Search        Code/Page

User Login



Forgot the Password?
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
» Regular Expr Tester
» Free Tools

Convert a decimal value to binary, octal, or hexadecimal

Total Hit ( 4259)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article



The ToString method of the Convert class lets you easily and quickly convert a decimal value into a string representation of that number to binary, octal, or hexadecimal base:

Click here to copy the following block
' convert to binary
Console.WriteLine(Convert.ToString(11, 2))  ' => 1011
' convert to octal
Console.WriteLine(Convert.ToString(123, 8))  ' => 173
' convert to hexadecimal
Console.WriteLine(Convert.ToString(254, 16))  ' => fe

The ToString method is overloaded to take a Byte, a Short, an Integer, or a Long value in the first argument; the second argument can only be 2, 8, 10, or 16, else an exception will be thrown.

Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with, SQL Server and other MS technologies. He is, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )

Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.