Use TryParse
method like this
int y;
int.TryParse(status,out y);
TryParse
method is return bool
that indicate if input is convertible to integer or not. If it is then it will convert into int and assign it to y
variable. If input can not be convert to int then value of y
will be 0
.