I have a class within VS2008 written in C#. The class is recursive.
When I nan instance of this class and view it whilst debugging, VS2008 stalls for a few seconds and then the debug session exits.
Any ideas what the problem might be.
The class is
public class TextSection
{
private bool used;
private string id;
private HL7V3_CD code;
private string title;
private string text;
public List<TextSection> section;
public TextSection()
{
used = false;
section = new List<TextSection>();
}
public bool Used
{
get { return used; }
}
public string Title
{
get { return title; }
set
{
used = true;
title = value;
}
}
public string Text
{
get { return text; }
set
{
used = true;
text = value;
}
}
public string Id
{
get { return id; }
set
{
used = true;
id = value;
}
}
public HL7V3_CD Code
{
get { return Code; }
set
{
used = true;
code = value;
}
}
}
When debugging a screenshot of VS2008 before it exits is shown here
The problem is this property
It will generate a StackOverflowException, when the debugger tries to get the value from property Code, cause Code calls itself instead of returning the value of a variable