c# – 使用数据注释的mvc模型中的默认值
发布时间:2020-12-15 06:54:59 所属栏目:百科 来源:网络整理
导读:可以使用数据注释来添加int属性的默认值 就像是 [DefaultValue=1]public int MyId {get; set;} 解决方法 尝试这个 – 在构造函数中设置默认值: public class YOURMODEL{ public int MyId { get; set; } public YOURMODEL() { MyId = 1; }}
可以使用数据注释来添加int属性的默认值
就像是 [DefaultValue=1] public int MyId {get; set;} 解决方法
尝试这个 – 在构造函数中设置默认值:
public class YOURMODEL { public int MyId { get; set; } public YOURMODEL() { MyId = 1; } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |