Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • C# Data Types
  • C# Decision Making
  • C# Methods
  • C# Delegates
  • C# Constructors
  • C# Arrays
  • C# ArrayList
  • C# String
  • C# Tuple
  • C# Indexers
  • C# Interface
  • C# Multithreading
  • C# Exception
Open In App
Next Article:
Int16.Equals Method in C# with Examples
Next article icon

Int64.Equals Method in C# with Examples

Last Updated : 04 Apr, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

Int64.Equals() Method is used to get a value that shows whether the current instance is equal to a specified object or Int64. There are 2 methods in the overload list of this method as follows:

  • Equals(Int64) Method
  • Equals(Object) Method

Int64.Equals(Int64)

This method is used to return a value indicating whether the current instance is equal to a specified Int64 value or not.

Syntax: public bool Equals (long obj);
Here, it takes a Int64 value to compare to this instance.

Return Value: This method returns true if obj has the same value as this instance otherwise, false.

Below programs illustrate the use of Int64.Equals(Int64) Method:

Example 1:




// C# program to demonstrate the
// Int64.Equals(Int64) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        // Declaring and initializing value1
        long value1 = 45643242;
  
        // Declaring and initializing value2
        long value2 = 2564233;
  
        // using Equals(Int64) method
        bool status = value1.Equals(value2);
  
        // checking the status
        if (status)
            Console.WriteLine("{0} is equal to {1}",
                                    value1, value2);
        else
            Console.WriteLine("{0} is not equal to {1}",
                                        value1, value2);
    }
}
 
 
Output:
  45643242 is not equal to 2564233  

Example 2:




// C# program to demonstrate the
// Int64.Equals(Int64) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
  
        // calling get() method
        get(44355, 578);
        get(423445, 423445);
        get(12560, 28960);
        get(778, 798);
    }
  
    // defining get() method
    public static void get(long value1,
                           long value2)
    {
  
        // using Equals(Int64) method
        bool status = value1.Equals(value2);
  
        // checking the status
        if (status)
            Console.WriteLine("{0} is equal to {1}",
                                    value1, value2);
        else
            Console.WriteLine("{0} is not equal to {1}",
                                        value1, value2);
    }
}
 
 
Output:
  44355 is not equal to 578  423445 is equal to 423445  12560 is not equal to 28960  778 is not equal to 798  

Int64.Equals(Object) Method

This method is used to returns a value indicating whether the current instance is equal to a specified object or not.

Syntax: public override bool Equals (object obj);
Here, it takes an object to compare with this instance.

Return Value: This method returns true if obj is an instance of Int64 and equals the value of this instance otherwise, false.

Below programs illustrate the use of the above-discussed method:

Example 1:




// C# program to demonstrate the
// Int64.Equals(Object) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        // Declaring and initializing value1
        long value1 = 1879650;
  
        // Declaring and initializing value2
        object value2 = 1/45;
  
        // using Equals(object) method
        bool status = value1.Equals(value2);
  
        // checking the status
        if (status)
            Console.WriteLine("{0} is equal to {1}",
                                    value1, value2);
        else
            Console.WriteLine("{0} is not equal to {1}",
                                        value1, value2);
    }
}
 
 
Output:
  1879650 is not equal to 0  

Example 2:




// C# program to demonstrate the
// Int64.Equals(Object) Method
using System;
using System.Globalization;
  
class GFG {
  
    // Main Method
    public static void Main()
    {
        // calling get() method
        get(54547, 54585);
        get(555, 489);
        get(10450, 10450);
        get(745, 745);
    }
  
    // defining get() method
    public static void get(long value1,
                        object value2)
    {
  
        // using Equals(object) method
        bool status = value1.Equals(value2);
  
        // checking the status
        if (status)
            Console.WriteLine("{0} is equal to {1}",
                                    value1, value2);
        else
            Console.WriteLine("{0} is not equal to {1}",
                                        value1, value2);
    }
}
 
 
Output:
  54547 is not equal to 54585  555 is not equal to 489  10450 is not equal to 10450  745 is equal to 745  

Reference:

  • https://docs.microsoft.com/en-us/dotnet/api/system.int64.equals?view=netframework-4.7.2


Next Article
Int16.Equals Method in C# with Examples

K

Kirti_Mangal
Improve
Article Tags :
  • C#
  • CSharp-Int64-Struct
  • CSharp-method

Similar Reads

  • Int16.Equals Method in C# with Examples
    Int16.Equals() Method is used to get a value which indicates whether the current instance is equal to a specified object or Int16. There are 2 methods in the overload list of this method which are as follows: Equals(Int16) Method Equals(Object) Method Int16.Equals(Int16) This method is used to retur
    4 min read
  • Int32.Equals Method in C# with Examples
    Int32.Equals() Method is used to get a value which indicates whether the current instance is equal to a specified object or Int32 or not. There are two methods in the overload list of this method as follows: Equals(Int32) Method Equals(Object) Method Int32.Equals(Int32) This method is used to return
    3 min read
  • SByte.Equals Method in C# with Examples
    SByte.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or SByte or not. There are 2 methods in the overload list of this method as follows: Equals(SByte) Method Equals(Object) Method SByte.Equals(SByte) Method This method is used to ret
    3 min read
  • Int64.CompareTo Method in C# with Examples
    Int64.CompareTo Method is used to compare the current instance to a specified object or Int64 and returns a sign of their relative values. There are 2 methods in the overload list of this method as follows: CompareTo(Int64) Method CompareTo(Object) Method Int64.CompareTo(Int64) Method This method is
    4 min read
  • Single.Equals() Method in C# with Examples
    Single.Equals() Method is used to get a value which indicates whether the two instances of Single represents the same value or not. There are 2 methods in the overload list of this method as follows: Equals(Single) Method Equals(Object) Method Single.Equals(Single) Method This method is used to retu
    3 min read
  • Double.Equals() Method in C# with Examples
    Double.Equals() Method is used to get a value that indicates whether the two instances of Double represent the same value or not. There are total of two methods in the overload list of this method as follows: Equals(Double) MethodEquals(Object) MethodDouble.Equals(Double) This method is used to retu
    3 min read
  • UInt32.Equals Method in C# with Examples
    UInt32.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or 32-bit unsigned integer or not. There are 2 methods in the overload list of this method as follows: Equals(UInt32) Method Equals(Object) Method UInt32.Equals(UInt32) Method This
    3 min read
  • UInt16.Equals Method in C# with Examples
    UInt16.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or 16-bit unsigned integer or not. There are 2 methods in the overload list of this method as follows: Equals(UInt16) Method Equals(Object) Method UInt16.Equals(UInt16) Method This
    3 min read
  • UInt64.Equals Method in C# with Examples
    UInt64.Equals Method is used to get a value which indicates whether the current instance is equal to a specified object or 64-bit unsigned long integer or not. There are 2 methods in the overload list of this method as follows: Equals(UInt64) Method Equals(Object) Method UInt64.Equals(UInt64) Method
    3 min read
  • Int32.CompareTo Method in C# with Examples
    Int32.CompareTo Method is used to compare the current instance to a specified object or Int32 and returns a sign of their relative values. There are 2 methods in the overload list of this method as follows: CompareTo(Int32) Method CompareTo(Object) Method Int32.CompareTo(Int32) Method This method is
    4 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences