我有以下代码,由于某种原因,我收到了错误:
WpfApplication1.exe 中发生了“System.StackOverflowException”类型的未处理异常
at the line :
this.JointName = joint;inside the
公共客户(字符串联合,字符串动作)
当我运行代码时。
Class1.cs 代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WpfApplication1
{
public class Customer
{
public String JointName { get; set; }
public String ActionName { get; set; }
public List<Customer> lst = new List<Customer>();
public Customer(String joint, String action)
{
this.JointName = joint;
this.ActionName = action;
this.lst.Add(new Customer(this.JointName, this.ActionName));
}
public List<Customer> GetList()
{
return this.lst;
}
}
}
MainWindow.xaml.cs 代码:
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Customer Data1 = new Customer("Joint1", "Action1");
List<Customer> List = Data1.GetList();
dataGrid1.ItemsSource = List;
}
}
}
你们能看到我在这里做错了什么吗?我不知道我在哪里可以有一个无限循环..