rspec/rules/S7130/vbnet/rule.adoc
2024-11-14 13:25:46 +01:00

26 lines
584 B
Plaintext

include::../description-dotnet.adoc[]
=== Code examples
==== Noncompliant code example
[source,csharp,diff-id=1,diff-type=noncompliant]
----
Dim Items As New list(Of Integer) From {1, 2, 3}
Dim FirstItem As Integer = 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]
----
Dim Items As New list(Of Integer) From {1, 2, 3}
Dim FirstItem As Integer = Items.First() ' Compliant
----
include::../resources-dotnet.adoc[]
include::../rspecator.adoc[]