You're getting a stack overflow because of this section:
public int val
return val == 10 ? 1 : 0;
_val = value;
method is referencing the property name and not the private variable name. This means when you get the value of
, your code goes into a never ending loop as the result references itself. In .Net this will eventually cause a stack overflow exception.