从资源循环 [英] Loop from Resources

查看:83
本文介绍了从资源循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有问题来连接一个文件字符串来从本地源加载图像,但是如何使用嵌入式资源呢?
如何解决错误"无法将类型'字符串'隐式转换为'System.Drawing.Bitmap'" for循环中的第2行?

for(int i = 0; i< 0; i ++)
{
string a = string.Concat( " Properties.Resources.Image",i);
MyBitmap = a;
DisplayImage();
}

I have no problem to concat a string of filename to load images from local source, but how to do it with embedded resources?
How to solve the error "Cannot implicitly convert type 'string' to 'System.Drawing.Bitmap'" at line 2 in the for loop?


            for (int i = 0; i < 0; i++)
            {
                string a = string.Concat("Properties.Resources.Image", i);
                MyBitmap = a;
                DisplayImage();
            }

推荐答案

使用ResourceManager.GetResourceSet()获取给定区域性的所有资源的列表。返回的ResourceSet实现IEnumerable(您可以使用foreach)。
Use ResourceManager.GetResourceSet() for a list of all resources for a given culture. The returned ResourceSet implements IEnumerable (you can use foreach).


这篇关于从资源循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆