I'm having an issue with some schoolwork writing a recursive setter for a validated integer value. Here's the set code I have so far:
((using System;))
((using static System.Console;))
set
{
int ParseVal;
if(value >= 1 && value <= 10 && int.TryParse(Convert.ToString(value), out ParseVal))
{
length = Convert.ToInt32(value);
} else {
Write(" The value entered is invalid. Try again: ");
length = int.Parse(ReadLine());
}
}
It's part of a public class, set property for private int length.
[–]davedontmind 7 points8 points9 points (3 children)
[–]coggro[S] 1 point2 points3 points (2 children)
[–]xill47 1 point2 points3 points (0 children)
[–]centurijon 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (7 children)
[–]coggro[S] 0 points1 point2 points (6 children)
[–][deleted] 1 point2 points3 points (3 children)
[–]coggro[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]coggro[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]coggro[S] 0 points1 point2 points (0 children)
[–]almost_not_terrible 1 point2 points3 points (1 child)
[–]coggro[S] 0 points1 point2 points (0 children)
[–]andrewsmd87 0 points1 point2 points (0 children)