Skip to content

Commit

Permalink
Merge pull request #2209 from alok-urmaliya/master
Browse files Browse the repository at this point in the history
Fixed grammatical error in documentation.
  • Loading branch information
JoshClose authored Jan 24, 2024
2 parents 9face76 + cace861 commit c206405
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/examples/prerequisites/using-and-dispose/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,15 @@
<div class="column">
<div class="content">
<h1 id="using-and-dispose">Using and Dispose</h1>
<p>Whenever you have an object the implements <code>IDisposable</code>, you need to dispose of the resource when you're done with it. Most classes that use unmanaged resources will implement <code>IDisposable</code>. This means a lot of classes in the <code>System.IO</code> namespace will need to be disposed of.</p>
<p>Whenever you have an object that implements <code>IDisposable</code>, you need to dispose of the resource when you're done with it. Most classes that use unmanaged resources will implement <code>IDisposable</code>. This means a lot of classes in the <code>System.IO</code> namespace will need to be disposed of.</p>
<p>The best practice to dispose of an object when you're done with it is to wrap the code in a <code>using</code> block. When the <code>using</code> block exits, the resource will automatically be disposed of as soon as possible.</p>
<pre><code class="language-cs">using (var stream = new MemoryStream())
{
// Use the stream.
}
// The stream will be disposed of as soon as possible.
</code></pre>
<p>If you need to keep keep it around for a while and dispose of it later, <code>using</code> does some error handling for you, so it's still a good idea to use it instead of calling <code>Dispose</code> directly. There is some debate on whether this is a good idea because it doesn't show intent.</p>
<p>If you need to keep it around for a while and dispose of it later, <code>using</code> does some error handling for you, so it's still a good idea to use it instead of calling <code>Dispose</code> directly. There is some debate on whether this is a good idea because it doesn't show intent.</p>
<pre><code class="language-cs">var stream = new MemoryStream();
// Later in a different part of your code.
using (stream) { }
Expand Down

0 comments on commit c206405

Please sign in to comment.