码迷,mamicode.com
首页 > 其他好文 > 详细

get,set

时间:2015-09-07 13:04:22      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:set   get   

class Program
    {
        static void Main(string[] args)
        {
            readName S1 = new readName();
            S1.MGo = Console.ReadLine();
            Console.WriteLine(S1.MGo + "__" + S1.MM);
            Console.ReadKey();
        }
    }

    class readName
    {
        public string MM;
        public string MGo
        {
            get
            {
                //读取MGo时执行的代码
                return "9999";
            }
            set
            {
                //设置MGo时执行的代码
                if (value == "1")
                {
                    this.MM = "Top";
                    return;
                }
                this.MM = value;
            }
        }
    }


get,set

标签:set   get   

原文地址:http://chikeyi.blog.51cto.com/7504707/1692205

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!