将颜色声明为常量 [英] Declare Color as constant

查看:70
本文介绍了将颜色声明为常量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何像这样将 Color 类型声明为 const :

How can I declare the Color type as const like this:

private const Color MyLovedColor = Color.Blue;

那是行不通的,因为Color.Blue是静态的而不是const.

That doesn't work because the Color.Blue is static not const.

(只读对我没有帮助,因为我需要仅支持常量"的属性的颜色

(readonly won't help me because I need the color for an attribute which "support" constants only

推荐答案

查看 KnownColor 枚举.它可能会满足您的需求.

Look at the KnownColor enumeration. It will likely cater for what you need.

这篇关于将颜色声明为常量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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