Comparing arrays for equality C# with Example



Comparing arrays for equality C# with Example

LINQ provides a built-in function for checking the equality of two IEnumerables, and that function can be used on 
arrays. 
The SequenceEqual function will return true if the arrays have the same length and the values in corresponding 
indices are equal, and false otherwise. 
 

int[] arr1 = { 3, 5, 7 }; 
int[] arr2 = { 3, 5, 7 }; 
bool result = arr1.SequenceEqual(arr2); 
Console.WriteLine("Arrays equal? {0}", result); 
This will print: 
Arrays equal? True 

0 Comment's

Comment Form

Submit Comment