include::../description-dotnet.adoc[]

=== Code examples

==== Noncompliant code example

[source,csharp,diff-id=1,diff-type=noncompliant]
----
var items = new List<int> { 1, 2, 3 };

int firstItem = items.FirstOrDefault(); // Noncompliant, this implies the collection might be empty, when we know it is not
----

==== Compliant solution

[source,csharp,diff-id=1,diff-type=compliant]
----
var items = new List<int> { 1, 2, 3 };

int firstItem = items.First(); // Compliant
----

include::../resources-dotnet.adoc[]

include::../rspecator.adoc[]
