I have string that contains "1.3" and I am checking with Date.TryParse method. It automatically converting 开发者_如何学运维into "1/3/2010". How to handle this?


Why 1.3f returns true on TryParse? Because the TryParse method take that as valid input. Probably, some of supported date formats separates token by dot. You may want to try method:
DateTime.TryParse(String, IFormatProvider, DateTimeStyles, DateTime%) and as IFormatProvider supply CultureInfo.createSpecificCulture("en-US or whatever you want").
or
DateTime.TryParseExact, which allows you to supply specific format to parse the string into a DateTime object.
加载中,请稍侯......
精彩评论