BLOG.CSHARPHELPER.COM: Get day, month, date, time, and number format information for the computer's locale in C#
Get day, month, date, time, and number format information for the computer's locale in C#
The System.Globalization namespace's InstalledUICulture object provides lots of static methods giving information about the computer's numeric, date, and time formatting. This example adds a bunch of these values to a ListView control. The following code shows how the program adds just a few of the values.
// Add a value to the result. private void AddItem(string name, string value) { ListViewItem lvi = lvwValues.Items.Add(name); lvi.SubItems.Add(value); }
// Add all values in an array. private void AddArrayItems(string name, string[] values) { for (int i = 0; i < values.Length; i++) { AddItem(name + "(" + i + ")", values[i]); } }
// Add all values in an integer array. private void AddIntegerArrayItems(string name, int[] values) { for (int i = 0; i < values.Length; i++) { AddItem(name + "(" + i + ")", values[i].ToString()); } }
Comments