get,set

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;
            }
        }
    }


你可能感兴趣的:(set,get)