In my base class, the one that the others inherit from, has these properties:
private int DEFAULT_DISPLAY_ORDER = 999999;
private DateTime DEFAULT_DT = new DateTime(1111,1,1);
public int? Id {
get
{
return Id.GetValueOrDefault(0);
}
set
{
if (DisplayOrder == null) DisplayOrder = DEFAULT_DISPLAY_ORDER;
Id = value;
}
}
public String Description { get; set; }
public int? DisplayOrder { get; set; }
But when I execute it, I get this error:
+ $exception {
Cannot evaluate expression because the current thread is in a stack
overflow state.}
System.Exception {System.StackOverflowException}
on line
if (DisplayOrder == null) DisplayOrder = DEFAULT_DISPLAY_ORDER;
What the heck is going on here?
Look at this:
Here, accessing
Idrequires that you first fetch…Id. Bang.Next:
Look at the second part. In order to set
Id, you have to… call the setter forId. Bang.You need a field for this: