Skip to content

Commit 0033e0f

Browse files
Missing using for Stream and StreamReader variables (#8559)
* Missing use for Stream and StreamReader variables The WebClient variable has a using Using client As New WebClient() These were missing the using: Ref data As Stream = client.OpenRead(args(0)) Ref reader As New StreamReader(data) The order of Close for reader.Close and data.Close was reversed. * Missed End Using End Using need for VB.net * Apply suggestions from code review Co-authored-by: Bill Wagner <[email protected]>
1 parent f3e8e9a commit 0033e0f

File tree

1 file changed

+7
-7
lines changed
  • snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientUserAgent/VB

1 file changed

+7
-7
lines changed

snippets/visualbasic/VS_Snippets_Remoting/NCLWebClientUserAgent/VB/useragent.vb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ Public Class Test
1616
' requested URI contains a query.
1717
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)")
1818

19-
Dim data As Stream = client.OpenRead(args(0))
20-
Dim reader As New StreamReader(data)
21-
Dim s As String = reader.ReadToEnd()
22-
Console.WriteLine(s)
23-
data.Close()
24-
reader.Close()
19+
Using data As Stream = client.OpenRead(args(0))
20+
Using reader As New StreamReader(data)
21+
Dim s As String = reader.ReadToEnd()
22+
Console.WriteLine(s)
23+
End Using
24+
End Using
2525
End Using
2626
End Sub
2727
End Class
28-
'</Snippet1>
28+
'</Snippet1>

0 commit comments

Comments
 (0)