string[] cells = new string[]{"1","2","3","4","5","6","7","8","9"};
if(int.TryParse(Console.ReadLine(), out int cell){Console.WriteLine($"Wow! your cell is {cell} and value in your cell is{cells[cell]}");}
public bool CheckCorrectIndex(int tries, int userInput, List<string> listObject, out string value){ if (userInput >= 0 && userInput <= 3) { value = listObject[userInput - 1]; return true; } else { tries--; InputInvalid(tries); } value = null; return false;}
public bool CheckCorrectIndex(int tries, int userInput, List<string> listObject, out string value){ if (userInput >= 0 && userInput <= 3) { value = listObject[userInput - 1]; return true; } else { tries--; InputInvalid(tries); } return false;}
int tries; public void SelectionScreen() { if (int.TryParse(userInput, out var input)) { } else { tries--; InputInvalid(); } } public void InputInvalid() { if (tries > 0) { Console.WriteLine($"\nInput Must Be An Integer. Try Again. {tries} Left."); SelectionScreen(tries); } else { Console.WriteLine("\nInvalid Input 3 Times. Returning To Welcome Screen."); Thread.Sleep(2000); Console.Clear(); Program program = new(); program.WelcomeScreen(); } }
bool valueIsInt = CheckInputIsInteger(tries, Console.ReadLine(), out userSelection);
if (CheckInputIsInteger(userInput, out var value)) { //do stuff with value } else { //not int }