.Net DefaultValueAttribute on Properties

前端 未结 6 1240
再見小時候
再見小時候 2020-12-01 21:28

I got this code in a user control:

[DefaultValue(typeof(Color), \"Red\")]
public Color MyColor { get; set; }

How can I change MyColor

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 21:52

    Are you initializing MyColor in your constructor?

    The DefaultValue attribute does not actually set any values. It simply instructs the designer for which value to not generate code and will also show the default value non-bold to reflect this.

提交回复
热议问题