本文介绍了如何在 C# 中找到 Properties.Resources 的所有成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 C# 程序集中有一些资源可以通过
I have some resources in a C# Assembly which I address by
byte[] foob = Properties.Resources.foo;
byte[] barb = Properties.Resources.bar;
...
我想遍历这些资源,而不必保留我添加的内容的索引.有没有返回所有资源的方法?
I would like to iterate through these resources without having to keep an index of what I have added. Is there a method that returns all the resources?
推荐答案
事实证明它们是属性而不是字段,所以:
It turns out they're properties rather than fields, so:
foreach (PropertyInfo property in typeof(Properties.Resources).GetProperties
(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
{
Console.WriteLine("{0}: {1}", property.Name, property.GetValue(null, null));
}
请注意,这还会为您提供ResourceManager"和Culture"属性.
Note that this will also give you the "ResourceManager" and "Culture" properties.
这篇关于如何在 C# 中找到 Properties.Resources 的所有成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!