如何在C#中找到Properties.Resources的所有成员
我在C#程序集中有一些资源,我在其中解决
byte[] foob = Properties.Resources.foo; byte[] barb = Properties.Resources.bar; ...
我想迭代这些资源,而不必保留我添加的索引。 是否有返回所有资源的方法?
编辑:事实certificate他们是属性而不是字段,所以:
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”属性。
尝试Assembly.GetManifestResourceNames()
。 这样叫:
Assembly.GetExecutingAssembly().GetManifestResourceNames()
编辑:要实际获取资源调用Assembly.GetManifestResouceStream()
或查看更多详细信息,请使用Assembly.GetManifestResourceInfo()
。
上述就是C#学习教程:如何在C#中找到Properties.Resources的所有成员分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/943138.html