Maybe something like this?
private static string[] m_CultureNames;
public static bool IsCultureNameValid(string cultureNameToValidate)
{
if (m_CultureNames == null)
{
CultureInfo[] allCultures =
CultureInfo.GetCultures(CultureTypes.AllCultures);
m_CultureNames = new string[allCultures.Length];
for (int i = 0; i < allCultures.Length; i++)
{
CultureInfo ci = allCultures[i];
m_CultureNames[i] = ci.Name;
}
}
int index = Array.IndexOf<string>(m_CultureNames,
cultureNameToValidate);
return (index != m_CultureNames.GetLowerBound(0) - 1);
}
On May 15, 8:48*am, alexandervanvee...@gmail.com wrote:
On 15 mei, 15:42, Martin Honnen <mahotr...@yahoo.dewrote:
alexandervanvee...@gmail.com wrote:
I'm working on a project where I have to check if a given string . a
valid culture name is.
Is there a way in .NET to do this very easy? The function I wrote for
this solution is not very elegant.
* *CultureInfo.GetCultureInfo(name)
throws an exception if name is a not a supported CultureInfo.
--
* * * * Martin Honnen --- MVP XML
* * * *http://JavaScript.FAQTs.com/
But that is not very elegant is it?