public class People { private string _Name = "小明"; public string Name { get { return _Name; } set { _Name = value; } } private int _Age = 15; public int Age { get { return _Age; } set { _Age = value; } } }
public class People { [DefaultValue("小明")] public string Name { get; set; } [DefaultValue(15)] public int Age { get; set; } }
标签:set,Name,get,C#,Age,知识,public,string,DefaultValueAttribute From: https://www.cnblogs.com/lgx5/p/16644481.html