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 8308369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:47:27+00:00 2026-06-08T18:47:27+00:00

When implementing the using keyword to instantiate an IO.StreamWriter object does that imply that

  • 0

When implementing the using keyword to instantiate an IO.StreamWriter object does that imply that .close is called on the object or .dispose? Or does it matter since once it hits the end using it is out of scope and will be garbage collected anyways?

  • 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-06-08T18:47:29+00:00Added an answer on June 8, 2026 at 6:47 pm

    The using keyword will call Dispose. However, by convention, Dispose and Close should always perform the exact same functionality, and be interchangable.

    As such, any resource that is IDisposable but also provides a Close() method, such as Stream derived classes, are fine to use within a using block.

    This is addressed in the Framework Design Guidelines explicitly: “it is important that you make the Close implementation identical to Dispose“…

    The MSDN help for IDisposable also suggests this: “The implementer of a class that has such a convention might choose to implement a public method with a customized name, such as Close, that calls the Dispose method.”

    Or does it matter since once it hits the end using it is out of scope and will be garbage collected anyways?

    It will not be garbage collected – after it is no longer in scope, and no longer referenced by any objects, it will be eligible for garbage collection. This means that it will (at least if written properly), eventually get cleaned up, but it may not happen for a long time – including not until the program terminates. The using block causes the resource (not the memory), such as the stream, to be closed immediately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom template checkbox that I am implementing using a viewbox (using
I'm implementing a keyword highlighter in Java. I'm using java.util.regex.Pattern to highlight (making bold)
I've got a client/server setup that I am implementing using a WCF Service (
In my code i m implementing swipe using the HorizontalScrollView for that i got
when implementing/using methods that return or work with instances of objects, what is the
I'm implementing enumeration using a base class that defines a variety of methods. The
Due to the flooding examples of implementing logger using Singleton pattern, I have just
There are a lot of question discussing the patterned was of implementing and using
I am implementing an application using ember.js and couchdb. I choose ember-resource as database
I am implementing a comet using AsyncHttpHandlers in my current asp.net application. According to

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.