Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
将“red”、“green”、“yellow”、“aliceblue”等字符串转换为实际 System.Drawing.Color 值的最佳方法是什么?
我在看反射,但似乎有些不对劲。
您可以使用 Color.FromName()
System.Drawing.Color 有一个静态方法:
public static Color FromName(string name)
像这样使用它:
Color c = Color.FromName("AliceBlue")
System.Drawing.Color.FromName("红色");