Hello R.A.M.,

"using" just simplify your work, because sometime you can forget to free

you resources

R> Hello,

R> (Sorry for my English...)

R> I am learning C# and I have a question:

R> is it good practice to use "using", for example:

R> using (SqlConnection connection = new

R> SqlConnection(ConnectionString))

R> {

R> connection.Open();

R> ...

R> connection.Close();

R> }

R> It could be also written:

R>

R> SqlConnection connection;

R> try

R> {

R> connection = new SqlConnection(ConnectionString);

R> connection.Open();

R> ...

R> }

R> catch (Exception ex)

R> {

R> ...

R> }

R> finally

R> {

R> connection.Close();

R> }

R> What are advanatges and disadvantages of each of these methods?

R> Thank you very much.

R> /RAM/

---

WBR,

Michael Nemtsev :: blog:

http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not

cease to be insipid." (c) Friedrich Nietzsche