using System;
using System.Collections.Generic;
using System.Text;namespace ConsoleApplication14
{
    public class S
    {
        private string s;
        public string N
        {
            get 
            { 
                return this.s; 
            }
            set
            {
                this.N = value; 
            }
        }
        public S(string s2)
        {            this.N = s2;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            S z = new S("ZHANG");
            Console.WriteLine(z.N);
        }
    }
}

解决方案 »

  1.   

    搞不懂你上面的 using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ConsoleApplication2
    {
        using System;
        using System.Collections.Generic;
        using System.Text;    namespace ConsoleApplication14
        {
            public class S
            {
                private string s;            public string S1
                {
                    get { return s; }
                    set { s = value; }
                }
                public S(string s2)
                {                S1 = s2;
                }
            }
            class Program
            {
                static void Main(string[] args)
                {
                    S z = new S("ZHANG");
                    Console.WriteLine(z.S1);
                }
            }
        }
    }
      

  2.   

    public string N 
            { 
                get 
                { 
                    return this.s; 
                } 
                set 
                { 
                    this.N = value; 
                } 
            } 
    在设置N时(给N赋值时),会造成无限递归。
      

  3.   

     set 
       { 
         this.N = value; 
       }  set 
        { 
            this.s = value; 
         }