How to check if two lists are equal in C#

1 Answer

0 votes
using System;
using System.Collections.Generic;
using System.Linq;
                     
public class Program
{
    public static void Main()
    {
        var list1 = new List<string>() { "python", "c#", "php", "nodejs", "java", "c" };
        var list2 = new List<string>() { "python", "c#", "php", "nodejs", "java", "c" };
         
        if (list1.SequenceEqual(list2)){
            Console.WriteLine("Lists are equal");
        }
    }
}
 
 
 
/*
run:
 
Lists are equal
 
*/

 



answered May 6, 2020 by avibootz
edited Jul 29, 2023 by avibootz

Related questions

3 answers 222 views
2 answers 206 views
1 answer 96 views
1 answer 111 views
2 answers 188 views
1 answer 189 views
...