Console.WriteLine("please enter start date");
string sStartdate = string.Empty;
sStartdate = Console.ReadLine();
DateTime dStartDate;
DateTime.TryParse(sStartdate, out dStartDate);
Console.Write(dStartDate);
Console.ReadLine();
// for miltiple entry use this solution ---------------------------------------------------
List<datetime> dtArray = new List<datetime>();
while (true)
{
Console.WriteLine("Enter date");
string sStartdate = string.Empty;
sStartdate = Console.ReadLine();
DateTime dStartDate;
if (DateTime.TryParse(sStartdate, out dStartDate))
{
dtArray.Add(dStartDate);
}
string sAns = "Y";
Console.WriteLine("Want to enter next (Y/N)?");
do
{
sAns = Console.ReadLine();
if (sAns.ToUpper() != "Y" && sAns.ToUpper() != "N")
Console.WriteLine("Invalid Input, Valid inputs are Y/N?");
} while (sAns.ToUpper() != "Y" && sAns.ToUpper() != "N");
if (sAns.ToUpper() == "N")
{
break;
}
}
foreach (var item in dtArray)
{
Console.WriteLine(item);
}
Console.ReadLine();