Search
Learn
Share

Test if two lists of strings have the same values in C#

The System.Linq namespace includes a useful method called SequenceEqual for this purpose:

using System.Linq;

var areTheSame = listOne.SequenceEqual(listTwo);

Example:
var newList = Helper.GetNewList();

if (!newList.SequenceEqual(existingList))
{
existingList = newList;

//DO SOMETHING WITH NEW LIST VALUES
}