Getsuyodev, Programming is mainly used when constructing an application. Programming requires knowledge of application domains, algorithms, and programming language expertise. Programming can be developed in different logic based on developer knowledge.

How to CultureInfo in C#



The CultureInfo class holds culture-specific information, such as the associated language, sublanguage, country/region, calendar, and cultural conventions. This class also provides access to culture-specific instances of DateTimeFormatInfo, NumberFormatInfo, CompareInfo, and TextInfo.

Culture information sample:

E.g.
  CULTURE - en-GB
  ENGLISH NAME - English (United Kingdom)

The cultures are generally grouped into three sets: the invariant culture, the neutral cultures, and the specific cultures. The cultures have a hierarchy, such that the parent of one particular culture is a neutral culture, and the parent of a neutral culture is the InvariantCulture. Parent property returns the neutral culture associated with a specific culture. If the resources for the particular culture are not available in the system, the support for the neutral culture is used; if the resources for the neutral culture are not available, the resources embedded in the main assembly are used.
The culture is a property of the executing Thread. This read-only property returns Thread.CurrentCulture. You can find the current culture information from.

Thread.CurrentThread.CurrentCulture.Name

The following C# program shows how to get all culture names in the .NET Framework. To use CultureInfo class you need to include System.Globalization namespace in your project.

using System;
using System.Threading;
using System.Globalization;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			//MessageBox.Show(Thread.CurrentThread.CurrentCulture.Name);
			foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
			{
				MessageBox.Show(ci.EnglishName+ " - " + ci.Name);
			}
		}
	}
}

Comments are closed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More