Note注意
Windows 中使用的用户界面语言是“CurrentUICulture”设置的一种功能。如果您的 Windows 副本装有多语言用户界面包 (MUI),则可以在控制面板中更改用户界面语言。有关更多信息,请参阅 Windows Server 2003, Windows XP & Windows 2000 MUI 站点。如果未安装 MUI,则可以用编程方式更改当前的 UI 区域性,如下所述。
复制代码
' Visual Basic ' Sets the UI culture to French (France). Thread.CurrentThread.CurrentUICulture = New CultureInfo("fr-FR") // C# // Sets the UI culture to French (France). Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR"); // Visual J# // Sets the UI culture to French (France). System.Threading.Thread.get_CurrentThread().set_CurrentUICulture( new CultureInfo("fr-FR"));
保存和生成解决方案。
复制代码
' Visual Basic ' Declare a Resource Manager instance. Dim LocRM As New ResourceManager("WindowsApplication1.WinFormStrings", GetType(Form1).Assembly) ' Assign the string for the "strMessage" key to a message box. MessageBox.Show(LocRM.GetString("strMessage")) // C# // Declare a Resource Manager instance. ResourceManager LocRM = new ResourceManager("WindowsApplication1.WinFormStrings",typeof(Form1).Assembly); // Assign the string for the "strMessage" key to a message box. MessageBox.Show(LocRM.GetString("strMessage")); // Visual J# // Declare a Resource Manager instance. ResourceManager LocRM = new ResourceManager("WindowsApplication1.WinFormStrings", System.Type. GetType("WindowsApplication1.Form1").get_Assembly()); // Assign the string for the "strMessage" key to a message box. MessageBox.Show(LocRM.GetString("strMessage"));
Note注意
默认情况下,ResourceManager 对象区分大小写。如果希望执行不区分大小写的查找(例如使“TXTWELCOME”与“txtWelcome”检索相同的资源),则可以将资源管理器的 IgnoreCase 属性设置为 true。但是,为了提高性能,最好始终为资源名称指定正确的大小写。如果执行不区分大小写的资源查找,则可能会导致性能问题。