c# - Check if a string contains date or not -


Viewing a string "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    

method.

  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

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -