Try to avoid
Parse(...)
or
Convert.ToInt(...)
.
Use
TryParse(...)
instead.
Reason: only
TryParse(...)
allows to react on parsing mismatches, the other two functions throw exceptions in that case.
E.g. If you try to parse and set to a default in case of a parse failure occurs, you may use the following:
static readonly int DEFAULT_FOR_V = 123;
...
string s = "...";
...
int v = int.TryParse(s, out v) ? v : DEFAULT_FOR_V;
...
Cheers
Andi