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:
C# | Check if two OrderedDictionary objects are equal
Next article icon

C# | Check if two StringCollection objects are equal

Last Updated : 01 Feb, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

Equals(Object) Method which is inherited from the Object class is used to check if a specified StringCollection object is equal to another StringCollection object or not.

Syntax:

public virtual bool Equals (object obj);

Here, obj is the object which is to be compared with the current object.

Return Value: This method return true if the specified object is equal to the current object otherwise it returns false.

Below programs illustrate the use of above-discussed method:

Example 1:




// C# code to check if two
// StringCollections are equal or not
using System;
using System.Collections.Specialized;
  
class GFG {
  
    // Driver code
    public static void Main()
    {
  
        // creating a StringCollection named myCol
        StringCollection myCol = new StringCollection();
  
        // Adding elements in StringCollection
        myCol.Add("A");
        myCol.Add("B");
        myCol.Add("C");
        myCol.Add("D");
        myCol.Add("E");
  
        // Checking whether myCol is
        // equal to itself or not
        Console.WriteLine(myCol.Equals(myCol));
    }
}
 
 
Output:
  True  

Example 2:




// C# code to check if two
// StringCollections are equal or not
using System;
using System.Collections.Specialized;
  
class GFG {
  
    // Driver code
    public static void Main()
    {
  
        // creating a StringCollection named my1
        StringCollection my1 = new StringCollection();
  
        // Adding elements in StringCollection
        my1.Add("GFG");
        my1.Add("Noida");
        my1.Add("DS");
        my1.Add("Geeks");
        my1.Add("Classes");
  
        // Creating a StringCollection named my2
        StringCollection my2 = new StringCollection();
  
        my2.Add("Australia");
        my2.Add("Belgium");
        my2.Add("Netherlands");
        my2.Add("China");
        my2.Add("Russia");
        my2.Add("India");
  
        // Checking whether my1 is
        // equal to my2 or not
        Console.WriteLine(my1.Equals(my2));
  
        // Creating a new StringCollection
        StringCollection my3 = new StringCollection();
  
        // Assigning my2 to my3
        my3 = my2;
  
        // Checking whether my3 is
        // equal to my2 or not
        Console.WriteLine(my3.Equals(my2));
    }
}
 
 
Output:
  False  True  

Note: If the current instance is a reference type, the Equals(Object) method checks for reference equality.



Next Article
C# | Check if two OrderedDictionary objects are equal

K

Kirti_Mangal
Improve
Article Tags :
  • C#
  • CSharp-method
  • CSharp-Specialized-Namespace
  • CSharp-Specialized-StringCollection

Similar Reads

  • C# | Check if two StringDictionary objects are equal or not
    Equals(Object) Method which is inherited from the Object class is used to check if a specified StringDictionary object is equal to another StringDictionary object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return
    2 min read
  • C# | Check if two Tuple Objects are equal
    A tuple is a data structure which gives you the easiest way to represent a data set. You can also check if the given tuple object is equal to the specified object or not using the Equals Method. This method will return true if the given tuple object is equal to the specified object, otherwise, retur
    2 min read
  • C# | Check if two OrderedDictionary objects are equal
    Equals(Object) Method which is inherited from the Object class is used to check if a specified OrderedDictionary object is equal to another OrderedDictionary object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Retur
    2 min read
  • Check if two SortedDictionary objects are equal in C#
    Equals(Object) Method which is inherited from the Object class is used to check if a specified SortedDictionary object is equal to another SortedDictionary object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return
    2 min read
  • C# | Check if two SortedList objects are equal
    Equals(Object) Method which is inherited from the Object class is used to check whether the specified SortedList object is equal to another SortedList object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value
    2 min read
  • C# | Check if two SortedSet<T> objects are equal
    Equals(Object) Method which is inherited from the Object class is used to check if a specified SortedSet<T> object is equal to another SortedSet<T> object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Ret
    2 min read
  • C# | Check if two List objects are equal
    Equals(Object) Method which is inherited from the Object class is used to check if a specified List<T> object is equal to another List<T> object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value:
    2 min read
  • C# | Check if two BitArray objects are equal
    Equals(Object) Method which is inherited from the Object class is used to check if a specified BitArray object is equal to another BitArray object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value: This meth
    2 min read
  • C# | Check if two HashSet<T> objects are equal
    Equals(Object) Method which is inherited from the Object class is used to check if a specified HashSet<T> object is equal to another HashSet<T> object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return
    2 min read
  • C# | Check if two ArrayList objects are equal
    Equals(Object) Method which is inherited from the Object class is used to check whether the specified ArrayList object is equal to another ArrayList object or not. Syntax: public virtual bool Equals (object obj); Here, obj is the object which is to be compared with the current object. Return Value:
    2 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