The following line of code return true (which it should not)….and convert 1.0228 into datetime…
DateTime.TryParse(1.0228,out temporaryDateTimeValue)
Somebody please help me.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will not compile.
However, if you wrap it in quotes (and clean it up a little bit),
then, yes, you will get
trueback. You need to read the documentation to understand why, but basically, there are many different ways to format dates and you stumbled on one (maybeM.yyyy?).If you don’t want it to parse, may I suggest
Then
successisfalse.I note from the remarks in the documentation:
Basically,
TryParse"tries" very hard to parse the string you give it (although the "Try" really refers to the fact that the method returns a bool for success/failure indication).