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 .

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 … 🙂

 

 

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

One Response

  1. How to convert Octal Number to Decimal ,... | .NET and C# | Syngu September 7, 2011 Reply
  2. Rob September 9, 2011 Reply
  3. How to convert HexaDecimal Number to Decimal , Octal and Binary Number using C | ProgramInDotnet October 23, 2011 Reply

Leave a Reply


x

Interesting BlogPosts to read

How to get an Enumerator from range of elements from ArrayList in C# ?
The code snippet shown in this blog post demonstrates how you can get the enumeraor from a range of ...
How to check for the column name in an SqlDataReader Object in C# ?
When working in ADO.NET for data access , there are times when you want to check to see if a column ...
Download - Pokemon Go for for Windows 10 (Third Party app)
Pokemon Go is one of the popular AR games for android and iOS devices and now , the game is made ava...