dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB7
Expertise: Intermediate
Sep 7, 2002

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Convert a decimal value to binary, octal, or hexadecimal

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:

' 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.
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date