Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Convert one number base to another using C#.net

 
webmaster forum
shefeekj  Offline
For Technical Information
Activity
0%
 
New Coder
Posts: 26
Topics: 11
WWW
April 14, 2009, 06:30:48 AM

Here is how to convert one number base to another (i.e. base 10 [decimal] to base 2 [binary]) in C# .net

Firstly Hexidecimal (base 16) to binary (base 2)

Code:
string binaryval;
binaryval= Convert.ToString(Convert.ToInt32(fromhex[i], 16), 2);

Next, Decimal (base 10) to Hex (base 16)

Code:
int yourinteger=100;
string hex=yourinteger.ToString(”X”);

Next, Decimal (base 10) to binary (base 2)

Code:
string bin=Convert.ToString(YourInteger, 2);

Hope this helps!
« Last Edit: April 14, 2009, 06:38:18 AM by polas »

http://www.shefeekj.com
 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
April 14, 2009, 06:54:42 AM

Thanks for posting these - very useful reference material

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 03, 2012, 06:04:14 PM