c# - 关于对象属性的问题,代码不知道写错了没?
本文介绍了c# - 关于对象属性的问题,代码不知道写错了没?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
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 ;}
}
}
}
运行提示停止运行,是我写错了吗?
解决方案
public class test
{
string _abc;
public string abc
{
get
{return _abc;}
set
{_abc=value ;}
}
}
你没发现属性abc在循环调用自己吗?
这篇关于c# - 关于对象属性的问题,代码不知道写错了没?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文