I have date in string format:
APRIL, 03/2013
How to convert to date object in C#
I have date in string format:
APRIL, 03/2013
How to convert to date object in C#
Use DateTime.ParseExact
:
DateTime dt = DateTime.ParseExact("APRIL, 03/2013", "MMMM, dd/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None);
I have used CultureInfo.InvariantCulture
(similar to english but culture independent) to enforce the /
separator in the format and to ensure that it works in any culture.
Note that /
has a special meaning in format strings. It means: replace me with the current culture's date separator.
See: the "/" Custom Format Specifier.