warnk
April 13th, 2009, 08:13 AM
I get some "System.StackOverflowException was unhandled" by running the following C# code, I don't understand why.
class Test
{
static void Main(string[] args)
{
Customer cust = new Customer();
cust.ID = 1;
cust.Name = "Parrot";
Console.WriteLine("ID: {0}, Name: {1}", cust.ID, cust.Name);
}
}
class Customer
{
public int ID { get; set; }
public string Name
{
get { return this.Name; }
set { this.Name = value.ToUpper(); }
}
}
class Test
{
static void Main(string[] args)
{
Customer cust = new Customer();
cust.ID = 1;
cust.Name = "Parrot";
Console.WriteLine("ID: {0}, Name: {1}", cust.ID, cust.Name);
}
}
class Customer
{
public int ID { get; set; }
public string Name
{
get { return this.Name; }
set { this.Name = value.ToUpper(); }
}
}