How it works
SequenceEqual compares two enumerations element by element. Matching values must occur in corresponding positions, and neither sequence may have an unmatched remainder. The default comparison treats the differently cased names as unequal, so the first result is false even though a person might read them as the same names.
The second call supplies StringComparer.OrdinalIgnoreCase and succeeds. The comparer changes how corresponding names are compared, but it does not remove the ordering requirement. Reversing the expected sequence still produces false because Ada and Sam occupy different positions. Equality policy and ordering policy remain separate parts of the contract.
This operator is useful for testing a deterministic query result. It can check that a sort, projection, or parser produces the expected ordered sequence without relying on a formatted string. If the product cares only about set membership, however, SequenceEqual is not the appropriate abstraction unless ordering has first been normalized deliberately.
Sorting both sides can remove meaningful evidence. A sequence of commands or event timestamps may be wrong precisely because the order changed. Before normalizing results for a test, decide whether order is part of the requirement. Tests should not accidentally weaken the behavior they claim to verify.
Practice by adding a duplicate name to one side, then by adding the same duplicate to both sides at different positions. Predict each comparison. Compare the result with a HashSet membership check and explain which operation preserves multiplicity and which one collapses duplicate values.
Finally, define an explicit comparer for a small record where only one field is considered the identity key. Use that comparer with SequenceEqual and inspect whether two differently ordered identity sequences should match. A clear comparison contract makes test failures informative: a failure can indicate missing elements, extra elements, wrong order, or a genuine value mismatch.
A working example
using System;
using System.Linq;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
string[] expected = { "Ada", "Sam" };
string[] sameNames = { "ada", "SAM" };
Console.WriteLine(expected.SequenceEqual(sameNames));
Console.WriteLine(expected.SequenceEqual(sameNames, StringComparer.OrdinalIgnoreCase));
Console.WriteLine(expected.SequenceEqual(expected.Reverse(), StringComparer.OrdinalIgnoreCase));
Expected output
False True False
Sequence equality requires equal lengths and corresponding elements in the same order.