c# - Check if a string contains date or not -
Viewing a string method. "15:30:20" and
"2011- 09-02 15:30:20 ", how do I dynamically check if the given string has a date or not?
"15:30:20" - & gt; Not valid "2011-09-02 15:30:20" = & gt; Use the valid
string [] Format = new string [] {"yyyy-MM-dd hH: mm: ss"}; String value = "2011-09-02 15:30:20"; Date time datetime; If (Datetime. TryParseExact (Value, Format, System Globalization. Culturan Infuriator, System Globalization. Datetime Timetimes, Presented Default, Date Time Out) Console. Videoline ("valid:" + datetime); Else Console.WriteLine ("Invalid");
Comments
Post a Comment