Process is terminated due to StackOverflowException.

tiantianxiaoqiang 2010-02-01 11:03:54
为什么运行的时候会有这个提示:
Process is terminated due to StackOverflowException.
代码如下:
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Student student1 = new Student();
student1.Score = 100;
Console.Write("最后得分是:" + student1.Score);
}
}
class Student
{
private string name;
private int _score;
public int Score
{
get { return _score; }
set { Score = value; }
}

}
}
...全文
293 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
gan001128 2011-12-19
  • 打赏
  • 举报
回复
看看结果,我也想知道
xunzhaohexie 2010-03-07
  • 打赏
  • 举报
回复
这个东西 回复来看看
michaelnami 2010-02-01
  • 打赏
  • 举报
回复
老大 你没构造函数啊
ztenv 2010-02-01
  • 打赏
  • 举报
回复
你的Score是你的Score属性,而不是你的字段,明白了吗?所以会溢出
ztenv 2010-02-01
  • 打赏
  • 举报
回复
public int Score
{
get { return _score; }
set { Score = value; }
红的改为:_score;

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧