CSharp - Write program to do Deadline Check

Requirements

You will write a program that prompts the user to enter an order deadline.

Present a warning if the user enters a date in the past.

Hint

To convert a date entered in text into the DateTime object, you use the Convert.ToDateTime method call.

Conversion fails if a nonexistent date is entered.

You can handle this using try-catch.

Convert.ToDateTime can accept a second parameter specifying the language to be used for the conversion.

Demo

using System;
class Program/*from ww w .  java2 s  .  com*/
{
    static void Main(string[] args)
    {
        // Input 
        Console.Write("Enter order deadline: ");
        string input = Console.ReadLine();
        DateTime enteredDeadline = Convert.ToDateTime(input);

        // Checking entered value 
        DateTime today = DateTime.Today;
        if (enteredDeadline < today)
        {
            Console.WriteLine("Error! You have entered date in the past.");
        }
        else
        {
            Console.WriteLine("Deadline accepted.");
        }
    }
}

Result