What is the difference between doing something like DateTime.Parse()
and Convert.ToDateTime()
they both produce the same result but is there any advantage of one over the other?
Asked
Active
Viewed 191 times
-1

Frank Odoom
- 1,545
- 18
- 19
-
2Possible duplicate of [What's the main difference between int.Parse() and Convert.ToInt32](https://stackoverflow.com/questions/199470/whats-the-main-difference-between-int-parse-and-convert-toint32) – Hesam Faridmehr May 13 '18 at 05:09
-
https://msdn.microsoft.com/en-us/library/system.datetime.parse(v=vs.110).aspx and https://msdn.microsoft.com/en-us/library/system.convert.todatetime(v=vs.110).aspx should be pretty accurate – TheGeneral May 13 '18 at 05:12
-
Well, to be fair, it's probably best to avoid both. 99 times out of 100, you only need to convert a string to date, and for that, `DateTime.TryParse` or `DateTime.TryParseExact` are the best options. – Zohar Peled May 13 '18 at 05:35
1 Answers
0
this sample maybe help you :
int.Parse(string s) : Simply, int.Parse (string s) method converts the string to integer. If string s is null, then it will throw ArgumentNullException. If string s is other than integer value, then it will throw FormatException. If string s represents out of integer ranges, then it will throw OverflowException.
Convert.ToInt32(string s) : Simply, Convert.ToInt32(string s) method converts the string to integer. If string s is null, then it will return 0 rather than throw ArgumentNullException. If string s is other than integer value, then it will throw FormatException. If string s represents out of integer ranges, then it will throw OverflowException.

mehdi farhadi
- 1,415
- 1
- 10
- 16