首页 新闻 会员 周边

怎么讲颜色的单词转换成RGB格式

0
悬赏园豆:20 [已解决问题] 解决于 2015-10-15 10:16

例如我现在得到一个颜色名字,用string类型接收,现在我想将这个String的颜色转成RGB的格式,有大神知道吗?

菜鸟中的大神的主页 菜鸟中的大神 | 初学一级 | 园豆:60
提问于:2015-10-15 09:29
< >
分享
最佳答案
0
static void Main(string[] args)
{
      var color = Color.FromName("Yellow");
      int a= color.A;
      int r = color.R;
      int g = color.G;
      int b = color.B;
      Console.WriteLine("{0}:{1}:{2}:{3}",a,r,g,b);
      Console.ReadKey();
}
收获园豆:20
李丶GuanYao | 小虾三级 |园豆:1228 | 2015-10-15 09:59

这个我试过了,FormName()方法里面的东西只能是一个枚举里面有的,假如我得到值,用一个string接收,是不可以的

菜鸟中的大神 | 园豆:60 (初学一级) | 2015-10-15 10:02

@菜鸟中的大神: 

不是很懂你是什么意思..难道不是一样的吗?.

static void Main(string[] args)
{
      string colorName = "Yellow";
      var color = Color.FromName(colorName);
      int a= color.A;
      int r = color.R;
      int g = color.G;
      int b = color.B;
      Console.WriteLine("{0}:{1}:{2}:{3}",a,r,g,b);
      Console.ReadKey();
}
李丶GuanYao | 园豆:1228 (小虾三级) | 2015-10-15 10:05

@李丶GuanYao: 好的,我试了一下,可以的了,谢谢的

菜鸟中的大神 | 园豆:60 (初学一级) | 2015-10-15 10:16
其他回答(1)
0

你不举例说清楚颜色名字,谁知道咋回答!

爱编程的大叔 | 园豆:30839 (高人七级) | 2015-10-15 10:09

没事了

支持(0) 反对(0) 菜鸟中的大神 | 园豆:60 (初学一级) | 2015-10-15 10:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册