Windows Phone Developers

Saturday, November 15, 2008

Formatted Output using C# (Integer to Hexadecimal) / (Integer to Decimal) / (Integer to Exponential notations)

How to Display an Integer in Hexadecimal, Decimal and Scientific notations using C# (.NET)

Composite formatting can be used to format the output into various forms as shown below

private static void ListNumbersAsHexOctSciFormat()

{

try

{

Console.WriteLine("Decimal Hexadecimal Exponential (Scientific)");

for (int i = 1; i <>

{

Console.WriteLine("{0:D} \t{0:X} \t{0:E}",i );

}

}

catch (FormatException dEX)

{

Console.WriteLine("Formatting Exception" + dEX.Message);

}

catch (Exception ex)

{

Console.WriteLine(ex.Message);

}

}

To convert a string use String.Format method

string S1 = String.Format("{0:X}", i);

Formatting Strings in C#, Formatted Output in C#, C# Convert Decimal to Hexadecimal, Decimal to Hexadecimal Conversion using C#, Integer to Scientific notation using C#, C# Scientific notations, C# Integer to Hexadecimal, C# Integer to Decimal, C# Integer to Exponential notations, .NET Integer to Decimal, .NET Integer to Exponential notations

Formatting Strings in .NET, Formatted Output in .NET, .NET Convert Decimal to Hexadecimal, Decimal to Hexadecimal Conversion using .NET, Integer to Scientific notation using .NET, .NET Scientific notations, .NET Integer to Hexadecimal

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment

kbAlertz.com :: Visual Studio 2005

kbAlertz.com :: Visual Studio 2008

kbAlertz.com :: Visual Basic 2005