C#什么会出现未处理的“System.StackOverflowException”类型的异常
classMuslmprove{publicstringSongTitle{get{returnSongTitle;}set{SongTitle=value;}}publ...
class Muslmprove
{
public string SongTitle {get{return SongTitle;} set{SongTitle = value;} }
public string Singer
{get { return Singer; } set { Singer = value; } }
public void StarPlayer()
{
Console.WriteLine("千千静听已启动....");
}
public void ChoosingSongs()
{
SongTitle = "千年缘";
Singer = "必然";
Console.WriteLine("歌曲已选择...\n 音乐:" + SongTitle + "\t" + "歌手:" + Singer);
Player();
}
public void Player()
{
Console.WriteLine("开始播放...\n 音乐:" + SongTitle + "\t" + "歌手:" + Singer);
}
}
static void Main(string[] args)
{
Muslmprove musicImprove = new Muslmprove();
musicImprove.StarPlayer();
musicImprove.ChoosingSongs();
}
}
} 展开
{
public string SongTitle {get{return SongTitle;} set{SongTitle = value;} }
public string Singer
{get { return Singer; } set { Singer = value; } }
public void StarPlayer()
{
Console.WriteLine("千千静听已启动....");
}
public void ChoosingSongs()
{
SongTitle = "千年缘";
Singer = "必然";
Console.WriteLine("歌曲已选择...\n 音乐:" + SongTitle + "\t" + "歌手:" + Singer);
Player();
}
public void Player()
{
Console.WriteLine("开始播放...\n 音乐:" + SongTitle + "\t" + "歌手:" + Singer);
}
}
static void Main(string[] args)
{
Muslmprove musicImprove = new Muslmprove();
musicImprove.StarPlayer();
musicImprove.ChoosingSongs();
}
}
} 展开
展开全部
汗啊, 因为 你的属性的get方法是 死循环!!
当然会报堆栈溢出的错误啦
正确写法是:
(1)简写:
public string SongTitle {get;set; }
(2)标准:
private string songTitle;
public string SongTitle
{
get
{ return this.songTitle;}
set
{ this.songTitle = value;}
}
当然会报堆栈溢出的错误啦
正确写法是:
(1)简写:
public string SongTitle {get;set; }
(2)标准:
private string songTitle;
public string SongTitle
{
get
{ return this.songTitle;}
set
{ this.songTitle = value;}
}
追问
那要怎么改 才能运行啊.....
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询