1.

What is the usage of SequenceEqual() method in C#?

Answer»

The SequenceEqual() method is USED in C# to check whether two sequences are equal or not.

The following is an example:

using System; using System.Linq; class Example {    STATIC VOID Main()    {        string[] arr1 = { "one", "two", "three" };        string[] arr2 = { "one", "four", "five" };        bool res = arr1.SequenceEqual(arr2);        Console.WriteLine(res);    } }

The output:

False

Let us see another example:

using System; using System.Linq; class Example {    static void Main()    {        string[] arr1 = { "HTML", "CSS", "JAVASCRIPT" };        string[] arr2 = { "HTML", "CSS", "JavaScript" };        bool res = arr1.SequenceEqual(arr2);        Console.WriteLine(res);    } }

The output:

True


Discussion

No Comment Found