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

This is my fouth and last 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 HexaDecimal Number to Decimal , Octal and Binary Number using C# in Windows Phone 7 .

public static class HexaConverter
{
   /// <summary>
   /// Hex2binaries the specified hexvalue.
   /// </summary>
   /// <param name="hexvalue">The hexvalue.</param>
   /// <returns></returns>
   public static string hex2binary(string hexvalue)
   {
      string binaryval = "";
      binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 2);
      return binaryval;
   }

   /// <summary>
   /// Hex2s the decimal.
   /// </summary>
   /// <param name="hexvalue">The hexvalue.</param>
   /// <returns></returns>
   public static string hex2Decimal(string hexvalue)
   {
      string binaryval = "";
      binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 10);
      return binaryval;
   }
   /// <summary>
   /// Hex2s the octal.
   /// </summary>
   /// <param name="hexvalue">The hexvalue.</param>
   /// <returns></returns>
   public static string hex2Octal(string hexvalue)
   {
      string binaryval = "";
      binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 8);
      return binaryval;
   }
}

Again , the Convert.ToString method and Convert.ToInt method was used to achieve this function .

Simple Isn’t it ?

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.

No Responses

  1. How to convert HexaDecimal Number to Decimal ,... | .NET | Syngu September 15, 2011 Reply

Leave a Reply


x

Interesting BlogPosts to read

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...
Open Wordpad from command line in Windows
You can use the command "Write" from command line in Windows to open the WordPad application.D:\>...
Popular cross-platform (android and iOS) to-do list app
In this blog post, we will cover some of the popular to-do list app that is available on different p...