Number Converter for WP7 – How to convert Decimal Number to Binary , HexaDecimal and Octal Number using C# ?

In this blog post and in the upcoming blog posts, i will share the source code of my small App for Windows Phone 7 (Number Converter for WP7).

The Number Converter for WP7 has got 50+ downloads. Although it’s not a big number, but for the first App that was developed in less than an hour is a great motivation for building more Windows Phone 7 Apps.

This Blog post describes how to convert a Decimal Number to Binary, Hexadecimal and Octal Number using C#.

In most of the cases, the built in functions of the .NET framework is used.

The most common function used to convert the numbers are Convert.ToString () and ToString with “X” as parameter for the Hexadecimal number.

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace NumberConverter
{
public static class DecimalConverter
{
     /// <summary>
     /// Converts the Decimal Number to Binary
     /// </summary>
     /// <param name="DecimalNumber"></param>
     /// <returns></returns>
     public static string DecimalToBinary(Int64 DecimalNumber)
     {
          return Convert.ToString(Convert.ToString(Convert.ToInt64(DecimalNumber), 2));
     }
     /// <summary>
     /// Converts the Decimal Number to Octal Number
     /// </summary>
     /// <param name="DecimalNumber"></param>
     /// <returns></returns>
     public static Int64 DecimalToOctal(Int64 DecimalNumber)
     {
          return Convert.ToInt64(Convert.ToString(Convert.ToInt64(DecimalNumber), 8));
     }
     /// <summary>
     /// Converts the Decimal Number to Octal
     /// </summary>
     /// <param name="DecimalNumber"></param>
     /// <returns></returns>
     public static string DecimalToHex(Int64 DecimalNumber)
     {
          return DecimalNumber.ToString("X"); ;
     }
 }
}

Want to try out the Number Converter for Windows Phone ? . You can download it from the marketplace from the below link via zune software and Windows Phone 7.

 

0 thoughts on “Number Converter for WP7 – How to convert Decimal Number to Binary , HexaDecimal and Octal Number using C# ?

  1. Pingback: How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ? | Ginktage

  2. Pingback: How to convert HexaDecimal Number to Decimal , Octal and Binary Number using C# ? | Ginktage

  3. Pingback: How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C | ProgramInDotnet

  4. Pingback: How to convert Binary Number to Decimal , HexaDecimal and Octal Number using C#

  5. Pingback: How to convert HexaDecimal Number to Decimal , Octal and Binary Number using C#

  6. Pingback: MonoDevelop 2.4 beta 1 is Released | Tech Blog

  7. Pingback: How to convert Binary Number to Decimal , HexaDecimal and Octal Number using C# ? | Windows Phone Rocks

  8. Pingback: How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ? | Windows Phone Rocks

  9. Pingback: Number Converter for WP7 – How to convert Decimal Number to Binary , HexaDecimal and Octal Number using C# ?MobileOSGeek

  10. Pingback: How to convert Binary Number to Decimal , HexaDecimal and Octal Number using C# ?MobileOSGeek

  11. Pingback: How to convert Octal Number to Decimal , HexaDecimal and Binary Number using C# ?MobileOSGeek

Leave a Reply

Your email address will not be published. Required fields are marked *