Learn Programming and technology with ease @ developerpublish.com

HomeCSharpHow to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ?

# How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ?

This is my third post of the series of the Number Converter for Windows Phone 7 sourcecode. In my previous posts I talked about

In this blog post , i describe or share the codeÂ  that converts a Octal Number to Decimal , HexaDecimal and Binary Number using C# in Windows Phone 7 .

## How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ?

```public static class OctalConverter
{
/// <summary>
/// Octals to binary.
/// </summary>
/// <param name="OctalNumber">The octal number.</param>
/// <returns></returns>
public static string OctalToBinary(string OctalNumber)
{
Int64 DecimalNumber = OctalToDecimal(OctalNumber);
string retVal = "";
retVal = DecimalConverter.DecimalToBinary(DecimalNumber);
return retVal;
}
/// <summary>
/// Octals to decimal.
/// </summary>
/// <param name="OctalNumber">The octal number.</param>
/// <returns></returns>
public static Int64 OctalToDecimal(string OctalNumber)
{
return Convert.ToInt64(Convert.ToString(Convert.ToInt64(OctalNumber,8), 10));
}
/// <summary>
/// Octals to hexa.
/// </summary>
/// <param name="OctalNumber">The octal number.</param>
/// <returns></returns>
public static string OctalToHexa(string OctalNumber)
{
Int64 DecimalNumber = OctalToDecimal(OctalNumber);
string retVal = "";
retVal = DecimalConverter.DecimalToHex(DecimalNumber);
return retVal;
}
}```

DecimalConverter is a static class that was described in my earlier blog post is again used . If you noticed the above sourcecode , I have tried to the .NET framework function to convert the number instead of writing my own logic â€¦ ðŸ™‚

### You May Also Like

#### C# Program to Display Upper Triangular Matrix

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...

#### C# Program to Demonstrate Bitwise Operators

This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...

#### C# Program to Interchange the Columns of a Matrix

This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...