Tag Archives: numeric formats

Display sample formats for different locales in C#

This example loops through the system’s defined locales and displays sample numbers, currency values, dates, and times in each. When the program starts, the following code executes. private void Form1_Load(object sender, EventArgs e) { float float_value = 1234.56f; decimal dec_value … Continue reading

Posted in internationalization, localization | Tagged , , , , , , , , , , | Leave a comment

Use custom numeric formats in C#

You can use formatting characters to display custom numeric formats for numeric values. These formats work with a variable’s ToString method as well as with string.Format. For example, the code (1.234).ToString(“0.00″) returns the value “1.23.” This example builds a ListView … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , | Leave a comment

Use custom date and time formats in C#

Note that custom date and time formats may not produce the result you want when you program runs in different locales. For example, the date January 23, 2010 should be displayed as 1/23/2010 in the United States but in as … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , | Leave a comment

Use standard numeric formats in C#

You can use numeric formatting characters to display numbers in particular formats. These formats work with a variable’s ToString method as well as with String.Format. For example, the code value.ToString(“C”) returns the variable value formatted as currency. These formats are … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , | Leave a comment

Use the DateTime class’s standard formatting methods in C#

The ToString and string.Format methods let you use formatting characters to format a DateTime value, but it’s not easy to remember all of the characters you might want to use. To make using standard formats easier, the DateTime class provides … Continue reading

Posted in formatting, strings | Tagged , , , , , , , , , , , , , , , | Leave a comment