ResourceManager fileText = null; string path = "ResourceCon.test.Language"; fileText = new ResourceManager(path, typeof(Test).Assembly); string res = fileText.GetString("PortalSettingKey_hisBoxFocus", new CultureInfo("en")); //new CultureInfo("zh-CN")
上面代碼中ResourceCon為類庫名。Test為類庫下的一個文件。需要在類庫下建一個test文件夾。放置兩個資源文件ResCon.test.Language.resources和ResCon.test.Language.zh-CN.resources
ResourceManager構造函數表示在集合里查找含有path名稱的resource文件
GetString方法表示指定語言查找key對應值