using System.Text.RegularExpressions;
public static void Main()
string Test = "26/3/2021";
Console.WriteLine(Convert.ToDateTime(Test.convertDate()));
public static class StringExtensions
public static DateTime convertDate(this string text)
Regex pattern = new Regex("^(.*?) ", RegexOptions.Compiled);
Match match = pattern.Match(text);
text = ((match.ToString()).Trim());
string[] subs = text.Split(' ', '/');
M = string.Concat("0",M);
d = string.Concat("0",d);
newValue = string.Concat(Y, "-", M, "-", d);
Console.WriteLine(newValue);
parsedDate = Convert.ToDateTime(newValue);