- , . , .
Your getter calls the setter, and the setter calls setter; it will be infinite recursion. You may need a storage box Position.
However, if we change it with saving in the field, and the setter does not actually affect. Thus, the code can be changed to:
public int Position {
set {
}
get {
int x;
return (x=Convert.ToInt32(Session["Position"]))>0?x:5;
}
}
You do not need to check for null, which Convert.ToInt32(null)is zero.
source
share