属性,简化get和set

来源:互联网 发布:mysql 恢复删除的表 编辑:程序博客网 时间:2024/04/25 23:14
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ClassStudy{    class Program    {        static void Main(string[] args)        {            Person xiaoMing = new Person();            xiaoMing.Age = 19;            Console.WriteLine(xiaoMing.Age);            Console.ReadKey();        }    }    class Person    {        private int age;        public int Age// 属性        {            set            {                this.age = value;            }            get            {                return this.age;            }        }    }}


原创粉丝点击