Parent class: Process is terminated due to StackOverflowException
alexiej opened this issue · comments
Hi,
I found in the code that it cannot manage Reference to parent. For example below code throw exception:
"Process is terminated due to StackOverflowException". Is it possible to write M parent as reference (like number "1" - because it was instanced before) ?
[ToString]
public class M
{
public string A { get; set; }
public string B { get; set; }
public int C;
private int D = 3;
public List<string> Hello { get; set; }
public M Parent { get; set; }
}
class Program
{
static void Main(string[] args)
{
var m = new M
{
A = "3",
B = "4",
C = 5,
Hello = new List<string>
{
"A",
"B",
"C"
}
};
m.Parent = m;
Console.Write(m.ToString());
Console.ReadKey();
}
}
Greate idea!
As a workaround, I guess you could [IgnoreDuringToString] attribute to Parent property.
closing this as stale. if it is still an problem please raise a new issue