读书人

读取资源文件中全部key和value

发布时间: 2013-02-28 11:33:09 作者: rapoo

读取资源文件中所有key和value
在项目中的Resources目录下有个A.Resx资源文件,文件里面有内容如下
a1 1
a2 2
现在想一次性读取所有key和value生成一个列表,如list,而不是通过具体的key一个一个的去找value
谢谢。在线等
[解决办法]

public static void Main() 
{
// Create a ResourceReader for the file items.resources.
ResourceReader rr = new ResourceReader("items.resources");


// Create an IDictionaryEnumerator to iterate through the resources.
IDictionaryEnumerator id = rr.GetEnumerator();

// Iterate through the resources and display the contents to the console.
while(id.MoveNext())
Console.WriteLine("\n[{0}] \t{1}", id.Key, id.Value);

rr.Close();

}

[解决办法]
http://msdn.microsoft.com/zh-cn/library/system.resources.resxresourcereader.aspx

读书人网 >C#

热点推荐