CSharp examples for Language Basics:Date Time
Compare two DateTime value
using System;//from w w w . j a v a 2 s . c o m using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; class Program { 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."); } } }