Getting error like :
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: String was not recognized as a valid DateTime.
I am using this code :
string datetime = DateTime.Parse(encrypt[1]);
or
string datetime = Convert.ToDatetime(encrypt[1]);
encrypt is a string array
In encrypt[1]
I am not sure which format will come in string
. i have trace some time come dd/MM/yyyy
and sometime MM/dd/yyyy
or MM-dd-yyyy
or dd-MM-yyyy
. I am not sure about format it may from above or another format come.
also use ParseExcept
and TryParseExcept
. but not get succeeded seems return same error
please give me proper solution.