I want my program to validate that the date format is mm/dd/yyyy
. I don't want to use any throw/catch blocks.
class FunWithScheduling
{
public void AddView()
{
...
...
Console.WriteLine("Enter the Date Scheduled For the Meeting:");
string Date = Console.ReadLine();
DateTime date = DateTime.Parse(Date);
string formatted = date.ToString("MM-dd-yyyy");
if (Date != formatted)
Console.WriteLine("Invalid Choice");
...
...
}
static void Main()
{
FunWithScheduling a = new FunWithScheduling();
a.AddView();
}
}