38 lines
665 B
Plaintext
38 lines
665 B
Plaintext
![]() |
:using_arg: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/using-statement[`Using` statement]
|
||
|
|
||
|
include::../why.adoc[]
|
||
|
|
||
|
== How to fix it
|
||
|
|
||
|
=== Code examples
|
||
|
|
||
|
==== Noncompliant code example
|
||
|
|
||
|
[source,vbnet,diff-id=1,diff-type=noncompliant]
|
||
|
----
|
||
|
Dim foo As New Disposable()
|
||
|
foo.Dispose()
|
||
|
foo.Dispose() ' Noncompliant
|
||
|
|
||
|
Using bar As New Disposable() ' Noncompliant
|
||
|
bar.Dispose()
|
||
|
End Using
|
||
|
----
|
||
|
|
||
|
==== Compliant solution
|
||
|
|
||
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
||
|
----
|
||
|
Dim foo As New Disposable()
|
||
|
foo.Dispose()
|
||
|
|
||
|
Using bar As New Disposable() ' Compliant
|
||
|
|
||
|
End Using
|
||
|
----
|
||
|
|
||
|
|
||
|
include::resources.adoc[]
|
||
|
|
||
|
include::../rspecator.adoc[]
|