如何在C#中找到Properties.Resources的所有成员

pet*_*ust 4 c# resources properties

我在C#程序集中有一些资源,我在其中解决

byte[] foob = Properties.Resources.foo;
byte[] barb = Properties.Resources.bar;
...
Run Code Online (Sandbox Code Playgroud)

我想迭代这些资源,而不必保留我添加的索引.有没有一种方法可以返回所有资源?

Jon*_*eet 5

编辑:事实证明他们是属性而不是字段,所以:

foreach (PropertyInfo property in typeof(Properties.Resources).GetProperties
    (BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))
{
    Console.WriteLine("{0}: {1}", property.Name, property.GetValue(null, null));
}
Run Code Online (Sandbox Code Playgroud)

请注意,这也将为您提供"ResourceManager"和"Culture"属性.