关于对象属性的问题,代码不知道写错了没?

using System;

namespace test
{

class Program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello World!");
        
        test hhh = new test();
        hhh.abc="hahaha";
        

        Console.Write(hhh.abc);
        Console.ReadKey();
    }
}


public  class test
{
    public string abc
    {
        get
        {return abc;}
        
        set
        {abc=value ;}
    }

}

}


运行提示停止运行,是我写错了吗?

阅读 2.2k
1 个回答
public  class test
{
    string _abc;
    public string abc
    {
        get
        {return _abc;}
        
        set
        {_abc=value ;}
    }

}

你没发现属性abc在循环调用自己吗?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进