Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 709313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:29:25+00:00 2026-05-14T04:29:25+00:00

I see this: using (StreamWriter sw = new StreamWriter(file.txt)) { // d0 w0rk s0n

  • 0

I see this:

using (StreamWriter sw = new StreamWriter("file.txt"))
{
     // d0 w0rk s0n
}

Everything I try to find info on is does not explain what this doing, and instead gives me stuff about namespaces.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T04:29:26+00:00Added an answer on May 14, 2026 at 4:29 am

    You want to check out documentation for the using statement (instead of the using directive which is about namespaces).

    Basically it means that the block is transformed into a try/finally block, and sw.Dispose() gets called in the finally block (with a suitable nullity check).

    You can use a using statement wherever you deal with a type implementing IDisposable – and usually you should use it for any disposable object you take responsibility for.

    A few interesting bits about the syntax:

    • You can acquire multiple resources in one statement:

      using (Stream input = File.OpenRead("input.txt"),
             output = File.OpenWrite("output.txt"))
      {
          // Stuff
      }
      
    • You don’t have to assign to a variable:

      // For some suitable type returning a lock token etc
      using (padlock.Acquire())
      {
          // Stuff
      }
      
    • You can nest them without braces; handy for avoiding indentation

      using (TextReader reader = File.OpenText("input.txt"))
      using (TextWriter writer = File.CreateText("output.txt"))
      {
          // Stuff
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currenlty using this to see if each rows check box in a
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
I am using an ItemsControl where the ItemsPanel is set to Canvas (see this
I'm using the Google Maps API. Please see this JSON response . The HTML
I am using the external library IMAPClient. When the login fails, i see this
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
I built wxWidgets on Linux using this command: ../configure --enable-shared --disable-debug It see results
This is something that I solved using reflection, but would like to see how
I have the following: C:\temp\dowork.exe < input.txt processing....... complete C:\ I try this: processArguments
Well, I'm sure this is not the first time to see this question. and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.