Take a look at below code:
void Main()
{
string one = "1399/07";
string two = "03/1400";
string three = "01/1400";
DateTime dOne = GetDate(one);
DateTime dTwo = GetDate(two);
DateTime dThree = GetDate(three);
bool answer = dThree>=dOne && dThree<=dTwo;
Console.WriteLine($"'{dThree.ToString("yyyy-MM-dd")}' is between '{dOne.ToString("yyyy-MM-dd")}' and '{dTwo.ToString("yyyy-MM-dd")}'? => {answer}");
}
public static DateTime GetDate(string initialValue)
{
int pos = initialValue.IndexOf("/");
string dformat = pos ==2 ? "MM/yyyy" : "yyyy/MM";
DateTime dDate = DateTime.MinValue;
DateTime.TryParseExact(initialValue, dformat, CultureInfo.GetCultureInfo("fa-IR"), DateTimeStyles.None, out dDate);
return dDate;
}
For further details, please see:
DateTime.TryParseExact Method (System) | Microsoft Docs[
^]
CultureInfo.GetCultureInfo Method (System.Globalization) | Microsoft Docs[
^]