Академический Документы
Профессиональный Документы
Культура Документы
Home Articles Quick Answers Discussions Zones Features Help! The Lounge Sea ch i e
» Languages » C # » General
ToS ring("00.00") - format do same thing as above replace zero if the number digit less , but
the zero after decimal point allows to display digit equals number of zero after decimal if the
number of digit less than display zero in place of that. output of the following code is 01.24 i.e
only 2 digit allowed after decimal point. Note : - decimal point is display as per specified
culture.
C ollapse | C opy C ode
value = 1.235;
Console.WriteLine("Format 2: " + value.ToString("00.00",
CultureInfo.InvariantCulture));
Console.WriteLine();
ToS ring("0,0") - format cause to display comma between number. here when the following
code is get executed , is get display after every three digit 1,234,567,890. Note : - in this
comma get replace by the culture.
C ollapse | C opy C ode
value = 1234567890;
Console.WriteLine("Format 3: " + value.ToString("0,0",
CultureInfo.InvariantCulture));
Console.WriteLine();
www.codeproject.com/Articles/399897/Format-Number-To-Displa 1/5
12/06/12 Format Number To Displa - CodeProject
format string description
Using RichEditC trl to Display
Formatted Logs
C ulture Specific Number Formatting
in ASP.NET
Format a number (with commas) in
SQL
XFormatNumber - A function to
format numbers with commas
C onvert numbers to words in
"#" C om Specifie English and Asian format
BitmaskC trl - Display and edit a
This specifier does same thing as "0" specifier do but the basic difference is it doesn't anything number as a bitmask
if the number is no equal to # where as "0" specifier replace 0 if digit not exists.
Number Validation and Formatting
using Javascript
ToS ring("#####") or ToS ring("#") - format allow to replace each digit by #, output of
JavaScript Number Parsing and
below code execution is 9867752985 which is differ from "0" specifier.
Formatting for Multicultural
Environments
C ollapse | C opy C ode
Telephone Numbers in SQL Server
value = 9867752985; 2005: Part 2 – Formatting
Console.WriteLine(value.ToString("#####")); Display line number in Visual Studio
Console.WriteLine(value.ToString("#"));
DataPager with Displaying Record
Console.WriteLine(); Number - Silverlight
Display line number in Visual Studio
Below code does same as above but format number by replace each # by each digit. so the
Formatting your numbers
output of the code is 98-67-75.
C ollapse | C opy C ode Transform between IEEE, IBM or
VAX floating point number formats
value = 986775; and bytes expressions
Console.WriteLine(value.ToString("[##-##-##]")); A Number of Reusable PE File
Console.WriteLine(); Format Scanning Functions
Below code execution again format number and output display it as (986) 77-52985
C ollapse | C opy C ode
value = 9867752985;
Console.WriteLine(value.ToString("(###) ###-####"));
Console.WriteLine();
Output
value = .869;
Console.WriteLine(value.ToString("00.##%", CultureInfo.InvariantCulture));
Console.WriteLine();
www.codeproject.com/Articles/399897/Format-Number-To-Displa 2/5
12/06/12 Format Number To Displa - CodeProject
value = 86;
Console.WriteLine(value.ToString("#0.##%", CultureInfo.InvariantCulture));
Console.WriteLine();
Output
Console.WriteLine(value.ToString("0.###E+000", CultureInfo.InvariantCulture));
Console.WriteLine();
value = -80;
Console.WriteLine(value.ToString("0.###E-000", CultureInfo.InvariantCulture));
Console.WriteLine();
Output
Output
www.codeproject.com/Articles/399897/Format-Number-To-Displa 3/5
12/06/12 Format Number To Displa - CodeProject
Source : http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
License
This article, along with any associated source code and files, is licensed under The Code
Project Open License (CPOL)
Prana Rana Hey, I am Pranay Rana, working as a ITA in MNC. Web development in
Asp.Net with C# and MS sql server are the experience tools that I
have had for the past 5.5 years now.
Follow on Twitter
26 Apr 2010: Best ASP.NET article of March 2010
23 Aug 2010: Best ASP.NET article of July 2010
2nd In ASP.NET article of December 2010
3rd In C# article of December 2010
4th In Overall article of December 2010
4th In Best overall article of February 2011
5th In Best C# article of February 2011
4th In Best ASP.NET article of April 2011
www.codeproject.com/Articles/399897/Format-Number-To-Displa 4/5
12/06/12 Format Number To Displa - CodeProject
Refresh
-- There are no messages in this forum --
P ermalink | A dvertis e | P rivac y | M obile L ayout: fixed | A rtic le C opyright 2 0 1 2 by P ranay Rana
Web0 4 | 2 .5 .1 2 0 6 0 4 .1 | L as t U pdated 7 J un 2 0 1 2 fluid E verything els e C opyright © C odeP rojec t, 1 9 9 9 - 2 0 1 2
T erms of U s e
www.codeproject.com/Articles/399897/Format-Number-To-Displa 5/5