C#彩恒R,G,B值 [英] C# Color constant R,G,B values
本文介绍了C#彩恒R,G,B值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在哪里可以找到所有的C#颜色的常量列表和相关的R,G,B(红,绿,蓝)值?
Where can I find a list of all the C# Color constants and the associated R,G,B (Red, Green, Blue) values?
例如
Color.White ==(255,255,255)
Color.White == (255,255,255)
Color.Black ==(0,0,0)
Color.Black == (0,0,0)
等等...
推荐答案
运行此程序:
using System;
using System.Drawing;
using System.Reflection;
public class Test
{
static void Main()
{
var props = typeof(Color).GetProperties(BindingFlags.Public | BindingFlags.Static);
foreach (PropertyInfo prop in props)
{
Color color = (Color) prop.GetValue(null, null);
Console.WriteLine("Color.{0} = ({1}, {2}, {3})", prop.Name,
color.R, color.G, color.B);
}
}
}
或者:
Or alternatively:
using System;
using System.Drawing;
public class Test
{
static void Main()
{
foreach (KnownColor known in Enum.GetValues(typeof(KnownColor)))
{
Color color = Color.FromKnownColor(known);
Console.WriteLine("Color.{0} = ({1}, {2}, {3})", known,
color.R, color.G, color.B);
}
}
}
这篇关于C#彩恒R,G,B值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文