TryParse
A method that tries to parse text and tells you whether it worked, instead of crashing.
The TryParse pattern returns a bool success flag and delivers the parsed value through an out parameter, avoiding exceptions for expected bad input.
Examples
if (int.TryParse(input, out int qty))hands youqtyonly when the text really was a number.
See also