Access localized resource strings without creating an instance of 'ResourceManager'?

后端 未结 2 1211
小鲜肉
小鲜肉 2020-12-06 14:51

I have created some resource files to hold strings. I am displaying a MessageBox by pointing it directly at a resource file named TestLocalResource

2条回答
  •  一整个雨季
    2020-12-06 15:42

    You don't need to use the ResourceManager explicitly.
    Have a look here: http://geekswithblogs.net/mapfel/archive/2008/11/01/126465.aspx
    To learn how to change the culture to use during runtime, see the second comment in the link:

    switch (comboBox1.Text)
    {
        case "neutral":
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("");
            break;
        case "en-GB":
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-GB");
            break;
        case "de-DE":
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");
            break;
    }
    
    string messageText = Messages.MsgSampleText;
    MessageBox.Show(messageText); 
    

提交回复
热议问题