【发布时间】:2010-12-31 03:11:00
【问题描述】:
我有以下自动属性
[DefaultValue(true)]
public bool RetrieveAllInfo { get; set; }
当我尝试在代码中使用它时,我发现默认的 false 是 false 我假设这是 bool 变量的默认值,有没有人知道出了什么问题!?
【问题讨论】:
-
Similar question。在 VS2015 中:
public bool RetrieveAllInfo { get; set; } = true;这是C# 6 功能。
标签: c# properties attributes default-value automatic-properties