Q:

C# program to determine whether two TimeZoneInfo objects are equal (TimeZoneInfo.Equals() Method)

belongs to collection: C# TimeZoneInfo Class Programs

0

Syntax:

    bool TimeZoneInfo.Equals(TimeZoneInfo TimeZone);

Parameter(s):

  • TimeZone: Time zone to be compared with current object.

Return value:

This method returns a boolean value if the given object is equal to the current object then it returns true otherwise it returns false.

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to determine whether two TimeZoneInfo objects are equal is given below. The given program is compiled and executed successfully.

using System;
using System.Globalization;
using System.Collections.ObjectModel;

class TimeZoneInfoDemo
{
    //Entry point of Program
    static public void Main()
    {
        TimeZoneInfo localTimeZone;
        TimeZoneInfo timeZone1;
        TimeZoneInfo timeZone2;

        localTimeZone = TimeZoneInfo.Local;

        timeZone1 = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");
        timeZone2 = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

        if (localTimeZone.Equals(timeZone1))
            Console.WriteLine("Both are equal");
        else
            Console.WriteLine("Both are not equal");

        if (localTimeZone.Equals(timeZone2))
            Console.WriteLine("Both are equal");
        else
            Console.WriteLine("Both are not equal");
    }
}

Output:

Both are not equal
Both are not equal
Press any key to continue . . .

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# TimeZoneInfo Class Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to get the hash code of the time zone (... >>
<< C# program to define a time zone that is not found...