c#:在一个dotnet类中有一个属性,说明"当前"文化是否真的是默认文化?

Mar*_*tin 7 c# culture localization resx cultureinfo

某些课程中是否有某个属性可以告诉我当前的文化是否真的是默认文化.

类似于本地化与winforms的工作方式.如果语言是默认的,它会以表格形式说明.

让我们说如果我在en-US - 我怎么能通过代码告诉en.US是否是实际的默认值?

我需要为.net不支持的某些XML文件实现一些本地化,因此我想实现自己的...

并做它winforms如何工作,即

nameofxml.default.xml (this is the default local)
nameofXml.de-de.xml (this is german) 

等等

财产存在吗?

Igo*_*hov 3

System.Globalization.CultureInfo.CurrentCulture表示系统的控制面板区域设置,同时System.Globalization.CultureInfo.CurrentUICulture对应于系统的输入 UI 语言设置(除非安装了多语言用户界面,否则无法更改)。

因此,您可以使用以下代码片段来确定“默认”区域性:

using System.Globalization;
// N.B. execute the following line *before* you programmatically change the CurrentCulture
// (if you ever do this, of course)

// Gets the CultureInfo that represents the culture used by the current thread
CultureInfo culture = CultureInfo.CurrentCulture;
string code = culture.IetfLanguageTag; // e.g. "en-US", "de-DE", etc.
Run Code Online (Sandbox Code Playgroud)

然后您可以使用code来查找您的 .xml 文件。