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

== How to fix it

=== Code examples

==== Noncompliant code example

[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Public Sub Method()
    Dim Values As New List(Of String)
    Values.Remove("bar")                ' Noncompliant
    If Values.Contains("foo") Then      ' Noncompliant
    End If
    For Each Value As String In Values  ' Noncompliant
    Next
End Sub
----

==== Compliant solution

[source,vbnet,diff-id=1,diff-type=compliant]
----
Public Sub Method()
    Dim Values As List(Of String) = LoadValues()
    Values.Remove("bar")
    If Values.Contains("foo") Then
    End If
    For Each Value As String In Values
    Next
End Sub
----

include::../rspecator.adoc[]
