How to check if two StringCollection objects are equal in C#

1 Answer

0 votes
using System;
using System.Collections.Specialized; 
                      
public class Program
{
    public static void Main()
    {
        StringCollection sc1 = new StringCollection(); 
  
        sc1.Add("c#"); 
        sc1.Add("c++"); 
        sc1.Add("c"); 
  
        StringCollection sc2 = new StringCollection(); 
  
        sc2.Add("c#"); 
        sc2.Add("c++"); 
        sc2.Add("c"); 
  
        Console.WriteLine(sc1.Equals(sc2)); 
		
		StringCollection sc3 = new StringCollection(); 
  
        sc3 = sc1; 
  
        Console.WriteLine(sc3.Equals(sc1)); 
		Console.WriteLine(sc3.Equals(sc2)); 
    }
}
  

  
/*
run:
  
False
True
False
  
*/

 



answered May 10, 2020 by avibootz

Related questions

2 answers 203 views
1 answer 108 views
1 answer 123 views
1 answer 175 views
175 views asked May 6, 2020 by avibootz
1 answer 139 views
1 answer 152 views
...