Posts Tagged ‘using’

using – There’s more there than you are using

If you’ve spent more than a day programming in csharp, you have already discovered the need for the using directive:

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Net;
using System.IO;

But are you aware of the other ways you can use this directive? Read the rest of this entry »

Dispose with Using

misc_vol3_087 I’m sure that many of you already know that many of the objects in the .NET framework need to be disposed.  The most common of these are the windows objects and the stream objects.

Of course the trick in using dispose is in calling it at the right time.  If your code throws an exception, you need to make sure that dispose still gets called on that object.

Read the rest of this entry »