Thursday, October 24, 2013

How to convert decimal to Binary, Octal, Hex conversion in C#

12:54 PM

How to convert decimal to Binary, Octal, Hex conversion in C#



Random rand = new Random();
int value = rand.Next(0, 1001);
String binaryRepresentation = Convert.ToString(value, 2);
String octalRepresentation = Convert.ToString(value, 8);
String base10Representation = Convert.ToString(value);
String hexRepresentation = Convert.ToString(value, 16);
// Any other bases and you are on your own.

// Go the other way.
int binary = Convert.ToInt32(binaryRepresentation, 2);
int octal = Convert.ToInt32(octalRepresentation, 8);
int base10 = Convert.ToInt32(base10Representation);
int hex = int.Parse(hexRepresentation, System.Globalization.NumberStyles.HexNumber); 
// alternative
Console.WriteLine("Binary: " + binaryRepresentation + " = " + binary.ToString());
Console.WriteLine("Octal: " + octalRepresentation + " = " + octal.ToString());
Console.WriteLine("Base10: " + base10Representation + " = " + base10.ToString());
Console.WriteLine("Hex: " + hexRepresentation + " = " + hex.ToString());














--------------------------------------------

Decimal To Octal C# Searches related to program to Convert Decimal to binary c#
convert decimal binary java
convert decimal binary visual basic
convert integer binary c#
convert decimal hexadecimal c#
c# convert decimal ascii
int to binary c#
Convert Decimal To Octal In C#
Converting Decimal To Octal C sharp
c# - Decimal to binary conversion in c #
Write a Program to convert Decimal to Binary in C#.NET
How convert decimal to binary
Converting decimal number into Octal number
C#: Decimal to Binary Conversion
Convert Decimal Number to Octal Number
How to convert numbers between hexadecimal and decimal in C#
Convert Type Decimal to Hex
C Sharp Code
Searches related to program to convert decimal to hexadecimal in c#
c# convert hex string to decimal
convert integer hexadecimal c#
convert decimal hexadecimal java
convert decimal binary c#
c# convert decimal ascii
c# to hex

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top