0
After watching a video I learned that int x = Convert.ToInt32(Console.ReadLine()); and int x = 0 x = int.Parse(Console.ReadLine()); essentially seem to be the same thing...why is that, and when would one way come in handy over the other?
3 Answers
+ 1
convert.ToInt32 will convert null value to zero while int.Parse will get an exception.
0
thanks, i think i understand now, not sure when I would need to use parse tho lol
0
Although int.TryParse(Console.ReadLine(), out a); would prevent the program from (sometimes) crashing when the user inputs a non-integer value.