在很多语言中,版本的切换都使用资源文件.c#也不例外,它的资源文件是后缀以.resx结尾的文件,不可否认这的确给我们带来了方便
首先:新建两个文件,比如:en.resx和zh.resx
在zh.resx里
名称 | 值 |
btnSubmitTxt | 提交 |
在en.resx里
名称 | 值 |
btnSubmitTxt | submit |
2.如何使用
1 using System.Globalization;
2 using System.Resources;

Code
1
private CultureInfo culture;
2
culture=CultureInfo.CurrentCulture;
3
if(culture.ToString()=="en")
4
{
5
radioButton1.Checked=true;
6
}
7
adjustCulture();
8
9
private void adjustCulture()
10
{
11
ResourceManager rm=new ResourceManager("HelloWorldGlobed.en",typeof(Form1).Assembly);
12
string btnHello=rm.GetString("btnSubmitTxt",culture),
13
button1.Text=btnHello; }
2 using System.Resources;


1

2

3

4



5

6

7

8

9

10



11

12

13
