在C#中,是否可以在C+中指定类似setlocale()的类别参数+;? static const int category[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME}; int op; ... /* op = 0; => The entire locale. */ op = 3; /* => Affects monetary formatting information */ char *setl = setlocale(category[op], "fr-FR");

在C#中,是否可以在C+中指定类似setlocale()的类别参数+;? static const int category[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME}; int op; ... /* op = 0; => The entire locale. */ op = 3; /* => Affects monetary formatting information */ char *setl = setlocale(category[op], "fr-FR");,c#,internationalization,culture,C#,Internationalization,Culture,我发现 Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR"); // OR Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); 我想这一定相当于 setlocale(LC_ALL,“fr”) 但在C#中,如何指定更改程序区域设置信息的category参数?您需要以类及其成

我发现

Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr-FR");
// OR
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
我想这一定相当于

setlocale(LC_ALL,“fr”)

但在C#中,如何指定更改程序区域设置信息的category参数?

您需要以类及其成员的身份进行操作,并在该实例之后相应地更改该信息的任何一部分

引用MSDN链接中的示例:

// Clones myCI and modifies the DTFI and NFI instances associated with the clone.
CultureInfo myCIclone = (CultureInfo) myCI.Clone();
myCIclone.DateTimeFormat.AMDesignator = "a.m.";
myCIclone.DateTimeFormat.DateSeparator = "-";
之后

Thread.CurrentThread.CurrentCulture = myCIclone;

好啊但是,与setlocale()的每个类别相对应的CultureInfo的属性是什么?@PapyRef:除了已经呈现的DateTimeFormat之外,您可以看到,在CultureInfo类中,DateTimeFormat始终是NumberFormat属性的一种类型。