The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Using in VB.NET

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Watermasysk

Posts: 661
Nickname: scottwater
Registered: Aug, 2003

Scott Watermasysk is an ASP.NET developers. He wrote the .Text blog engine.
Using in VB.NET Posted: Jun 8, 2004 5:34 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Scott Watermasysk.
Original Post: Using in VB.NET
Feed Title: ScottW's ASP.NET WebLog
Feed URL: /error.aspx?aspxerrorpath=/blog/rss.aspx
Feed Description: ASP.NET and Blogging
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Watermasysk
Latest Posts From ScottW's ASP.NET WebLog

Advertisement

I have not touched VB.NET since early in .NET Beta 1, so I am a bit rusty. One thing I was happy to find is support for using statements in VB.NET 2005. It took me a try or two to figure out the syntax, so I figured I would post it here for future reference.

Public Class Class1

    Public Sub Go()
        Using sw As StreamWriter = New StreamWriter("C:\hey.txt")
            sw.Write("HEY")
        End Using
    End Sub

End Class

via MSDN: "The using statement obtains one or more resources, executes a statement, and then disposes of the resource."

For those unfamailar with a using statement, you can use for classes which implement IDisposable. As soon as the variable defined in the using section goes out of scope, Dispose is called.

Read: Using in VB.NET

Topic: .NET Nightly 158 Previous Topic   Next Topic Topic: Java Developer Resource Center is Live!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use