Is there a set of constants or an enumeration in C# system/globalization namespace which contains valid culture names?
I am looking for something so that I don’t have to type in “en-GB”, etc.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No there isn’t. The list of available cultures is system-specific – you can even register new custom cultures using CultureAndRegionInfoBuilder.
So if you want this, you’ll have to create your own enum or constants for the subset of common cultures that you’re interested in, e.g.:
or
This is analogous to the
KnownColorenumeration: it’s not possible to create an enumeration for all possible colors, but it can make sense to have an enumeration for frequently used ones.I wouldn’t expect Microsoft to provide an equivalent
KnownCultureenumeration out of the box, as it’s rather sensitive (why is my culture not included?).