编程语言
首页 > 编程语言> > C#小知识特殊的DefaultValueAttribute

C#小知识特殊的DefaultValueAttribute

作者:互联网

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
来源: https://www.cnblogs.com/lgx5/p/16644481.html