I assume the following code is Correct,
CultureInfo culture = CultureInfo.GetCulture("en-US");开发者_如何学编程 Assert.IsTrue(culture.GetConsoleFallbackUICulture().Name == "en");
but it is not, culture.GetConsoleFallbackUICulture().Name is still "en-US", I want to know what is the API to get the fallback culture.
Thanks Jeff
This is correct, en-US does not need to fallback, that's why it returns en-US.
Only cultures in this list are affected: http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.getconsolefallbackuiculture.aspx
EDIT: if you want to do what's in your comment, use the CultureInfo.Parent property.
CultureInfo culture = CultureInfo.GetCulture("en-US");
Assert.IsFalse(culture.IsNeutralCulture); // en-US is NOT Neutral
Assert.IsTrue(culture.Parent.Name == "en"); // Our parent's culture is the neutral english culture
Assert.IsTrue(culture.Parent.IsNeutralCulture); // en is Neutral
Assert.IsTrue(culture.Parent.Parent.Name == ""); // Our grandparent's culture is the invariant culture
精彩评论