string类型如何转到color类的对象
实现这样的功能:定义string[] str_color = { "Color.Blue ", "Color.Red ", "Color.Orange ", "Color.Black ", "Color.Red "};
通过循环调用color[i]从而显示pictureBox.BackColor的不同颜色.
请问各位该怎么实现?
提示:系统无法将 "string "型转换为system.drawing.color类
------解决方案--------------------foreach(string str_c in str_color)
{
pictureBox.BackColor = Color.FromName(str_c);
}
------解决方案--------------------但是为啥要用字符串呢?
这样不好吗?
Color[] arrColor = {Color.Blue, Color.Red, Color.Orange, Color.Black, Color.Red};