Reputation: 91
public class Nodes
{
private Nodes nodeOne;
private Nodes nodeTwo;
private NodeType type;
private string extraInfo;
public Nodes(NodeType type, string info)
{
this.type = type;
this.extraInfo = info;
}
public Nodes node_One
{
get { return this.nodeOne; }
set { this.nodeOne = value; }
}
public Nodes node_Two
{
get { return this.node_Two; }
set { this.nodeTwo = value; }
}
public NodeType nodeType
{
get { return this.type; }
set { this.type = value; }
}
public string extraInf
{
get { return this.extraInfo; }
set { this.extraInfo = value; }
}
}
enum NodeType
{
AND,
OR,
PROPOSITION,
}
and I use it here:
if (dsPubs.Tables["Diccionario"].Rows.Contains(cmATomic.SelectedItem))
{
aux = new Nodes(NodeType.PROPOSITION, cmATomic.SelectedText);
nodeList.Add(aux);
}
so, every time i try to make an object an insert it in a list of nodes, it does , but when I put a break point in the list just to figure out what is storing in each position on the list , it gives me an weird mistake and the program suddenly end without not giving any kind of exception. when i hover the mouse over the List just to see the collection it apperas somtheing like this
[?]
[?]
[?]
[?]
and the program ends.
Upvotes: 0
Views: 55
Reputation: 218828
You have an infinite recursion here:
public Nodes node_Two
{
get { return this.node_Two; }
Any attempt to read the property node_Two
will result in a stack overflow exception. Not just in your program but in Visual Studio itself.
You probably meant this:
public Nodes node_Two
{
get { return this.nodeTwo; } // <-- use the variable, not the property
Note that consistent and sensible variable naming can help a lot to prevent mistakes like this.
Upvotes: 3