Using LINQ we can check sequence match on all elements in same order for two different array.
We are using "SequenceEqual" LINQ method to check. This method returns "true" if sequence match else return "false".
Here is LINQ "SequenceEqual" Method example.
In this example we take two string array one is "arrayOne" and second is "arrayTwo". Now we use "SequenceEqual" method to check that is both array has the same sequence of element. You can see output below.
C#. Net Example :
VB.Net Examples :
Output :
We are using "SequenceEqual" LINQ method to check. This method returns "true" if sequence match else return "false".
Here is LINQ "SequenceEqual" Method example.
In this example we take two string array one is "arrayOne" and second is "arrayTwo". Now we use "SequenceEqual" method to check that is both array has the same sequence of element. You can see output below.
C#. Net Example :
var arrayOne = new string[] { "1", "vb.Net", "asp.Net" }; var arrayTwo = new string[] { "1", "vb.Net", "asp.Net" }; bool isMatch = arrayOne.SequenceEqual(arrayTwo); Response.Write("The sequences match :" + isMatch);
VB.Net Examples :
Dim arrayOne = New String() {"1", "vb.Net", "asp.Net"} Dim arrayTwo = New String() {"1", "vb.Net", "asp.Net"} Dim isMatch As Boolean = arrayOne.SequenceEqual(arrayTwo) Response.Write("The sequences match :" & isMatch)
Output :
No comments:
Post a Comment