C# DateTime GreaterThan

Description

DateTime GreaterThan determines whether one specified DateTime is later than another specified DateTime.

Syntax

DateTime.GreaterThan has the following syntax.


public static bool operator >(
  DateTime t1,
  DateTime t2
)

Parameters

DateTime.GreaterThan has the following parameters.

  • t1 - The first object to compare.
  • t2 - The second object to compare.

Returns

DateTime.GreaterThan method returns true if t1 is later than t2; otherwise, false.

Example

The following code shows how to use DateTime.GreaterThan operator.


using System;/*from   www.ja  va 2s  . c  om*/
public class MainClass{
  public static void Main(String[] argv){  
            System.DateTime april19 = new DateTime(2001, 4, 19);
      System.DateTime otherDate = new DateTime(1991, 6, 5);

      bool result = april19 > otherDate;
      System.Console.WriteLine(result);
        
      otherDate = new DateTime(2001, 4, 19);

      result = april19 > otherDate;

            System.Console.WriteLine(result);
  }
}
  

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version