read about these 2 methods and class on different sites. With CONVERT everything is clear, but with 2-methods related complexity and what are their differences?
Answer 1, Authority 100%
int.parse (String S)
method tries to get the number from its string view, if successful returns the number, otherwise throws formatexception
.
int.tryparse (String S, Out int Result)
checks whether it is possible to get a number from a string. If possible, returns True
and the obtained number OUT
-AMER, otherwise returns false
result and Default (int)
Out
-pameter.
This is if it is simple, other exceptions can be emitted, depending on what the string you pass.
Example of using the second method:
string s = console.ReadLine ();
if (int.tryparse (S, Out int i))
Console.Writeline ("Number, increased by 5: {0}", I + 5);
ELSE.
Console.Writeline ("The introduced string was not number.");