when I want to convert a string to an int, I use Int.TryParse which returns true, when the string can be parsed and also has an out param with the string value.
Code: Select all
var str := "123"
if int.TryParse(str, out var strAsInt)
// do something with the value strAsInt
endif
In C#, I would use _ to discard the value.
Code: Select all
static bool StringIsInt(string value)
{
return int.TryParse(value, out _);
}
Kind regards
Volkmar