I want to convert a string in a specific format to a DateTime
.
My specific string format is \"dd-mm-yyyy
\".
I cannot do any string
It seems you want the static ParseExact method to which you can specify the actual date-time format.
var convertedDate = DateTime.ParseExact(input, "dd-MM-yyyy", null);
(Depending on the context, you may also want to specify CultureInfo.InvariantCulture
instead of null
/current culture as an argument.)