Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# if-else或开关的当前CultureName?_C#_If Statement_Localization_Cultureinfo_Currentculture - Fatal编程技术网

C# if-else或开关的当前CultureName?

C# if-else或开关的当前CultureName?,c#,if-statement,localization,cultureinfo,currentculture,C#,If Statement,Localization,Cultureinfo,Currentculture,我需要一个if或switch语句来指定当前名称。我找不到解决办法 这个代码不起作用 if (Thread.CurrentThread.CurrentCulture == new CultureInfo("en")) { // EN (default) } if (Thread.CurrentThread.CurrentCulture == new CultureInfo("de")) {

我需要一个if或switch语句来指定当前名称。我找不到解决办法

这个代码不起作用

        if (Thread.CurrentThread.CurrentCulture == new CultureInfo("en"))
        {
            // EN (default)
        }

        if (Thread.CurrentThread.CurrentCulture == new CultureInfo("de"))
        {
            // DE
        }

取决于你所说的“CultureName”

那么你的情况呢

  // German, Germany (and not Austria)
  if (Thread.CurrentThread.CurrentCulture.Name.Equals("de-DE")) {
    ...
  }
  else if (Thread.CurrentThread.CurrentCulture.Name.Equals("de-AT")) {
    // German, but Austrian subculture
    ...
  }


取决于你所说的“CultureName”

那么你的情况呢

  // German, Germany (and not Austria)
  if (Thread.CurrentThread.CurrentCulture.Name.Equals("de-DE")) {
    ...
  }
  else if (Thread.CurrentThread.CurrentCulture.Name.Equals("de-AT")) {
    // German, but Austrian subculture
    ...
  }


呃,
Thread.CurrentThread.CurrentCulture.Name
?然而另一种可能性是
Thread.CurrentThread.CurrentCulture.TwoLetterIsLanguageName
(取决于您所说的“CultureName”)呃,
Thread.CurrentThread.CurrentCulture.Name
?然而,另一种可能是
Thread.CurrentThread.CurrentCulture.TwoLetterIsLanguageName
(取决于您所说的“CultureName”)谢谢:-)对不起,我指的是应用程序的当前语言,而不是来自系统的语言。我使用System.Speech.Synthesis<代码>合成。选择VoiceByHits(VoiceGender.Female,VoiceAge.Senior,12岁,CultureInfo.CreateSpecificCulture(“en”)您的示例是针对当前系统语言的。谢谢:-)对不起,我指的是应用程序当前语言的语言,而不是来自系统的语言。我使用System.Speech.Synthesis<代码>合成。选择VoiceByHits(VoiceGender.Female,VoiceAge.Senior,12岁,CultureInfo.CreateSpecificCulture(“en”)您的示例适用于当前系统语言。
  // German, any subculture, dialect ect.
  if (Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Equals("de")) {
    ...
  }