有没有一种方法可以遍历.resxC#文件中的所有资源?
.resx
您应该始终使用资源管理器,而不是直接读取文件,以确保考虑到全球化。
using System.Collections; using System.Globalization; using System.Resources; ... ResourceManager MyResourceClass = new ResourceManager(typeof(Resources /* Reference to your resources class -- may be named differently in your case */)); ResourceSet resourceSet = MyResourceClass.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true); foreach (DictionaryEntry entry in resourceSet) { string resourceKey = entry.Key.ToString(); object resource = entry.Value; }