473,513 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using Statment

Please let me know on the usage of 'Using' keyword when used in statments.
Eg;
using (System.IO.StreamWriter varFile = new
System.IO.StreamWriter("fileName")).
Thanks,
RKNET
May 31 '06 #1
2 1239
Hi Rknet,

The using statement is a convenient way to ensure that the Dispose() method
of IDisposable
(http://msdn2.microsoft.com/en-us/lib...isposable.aspx) objects
are called properly. The object in the parameter must be IDisposable.
Without this statement, you would need to implement a try/finally statement
where you called Close() or Dispose in the finally block. I personally like
the statement and use it whenever I can.

Joe
--
http://www.csharp-station.com
"RKNET" wrote:
Please let me know on the usage of 'Using' keyword when used in statments.
Eg;
using (System.IO.StreamWriter varFile = new
System.IO.StreamWriter("fileName")).
Thanks,
RKNET

May 31 '06 #2
Thank you Joe.
--
RKNET
"Joe Mayo (C# MVP)" wrote:
Hi Rknet,

The using statement is a convenient way to ensure that the Dispose() method
of IDisposable
(http://msdn2.microsoft.com/en-us/lib...isposable.aspx) objects
are called properly. The object in the parameter must be IDisposable.
Without this statement, you would need to implement a try/finally statement
where you called Close() or Dispose in the finally block. I personally like
the statement and use it whenever I can.

Joe
--
http://www.csharp-station.com
"RKNET" wrote:
Please let me know on the usage of 'Using' keyword when used in statments.
Eg;
using (System.IO.StreamWriter varFile = new
System.IO.StreamWriter("fileName")).
Thanks,
RKNET

May 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1582
by: e_AK_05 | last post by:
I have a question and I can't figure out how to do it. I have a select statment : SELECT table1.* AS table1.*, table2.* AS table2.* FROM table1, table2 WHERE 1 this does not work...for me at...
1
4669
by: Joe Saliba | last post by:
Hi, would like to know how to write a crosstable select statment in sql server2000 where having: - ItemNumber, ItemDescription, ItemColor, ItemSize as rows - Stores as columns - Qty * Netttc...
9
15701
by: Appel | last post by:
Hallo i have a problem to add to string with a SQL statement. My Table : Tablename NAMES: | Name1 | Name2 | Name3 | John Meyer I search for a SQL statment that update Name3.
1
1729
by: Me, Myself, and I | last post by:
First off, i apologize if my terminology is off... I am currently in a project that is basically a front-end to a database. In coding this, I am taking into account that it has the *potential*...
5
3202
by: vsteshenko | last post by:
Hello, This is my second post to the any usernet group and the first one was posted to the wrong one. I am currently working on creating an order form for sales associates at my work to be used...
1
1574
by: zeebiggie | last post by:
Good morning I have a form with the controls in the insert statment below. table1 has an Auto increment primary key hence is omitted in the insert statment and form. Am getting the error It didnt...
1
1345
by: shivendravikramsingh | last post by:
hello friends, actually i have a problem in using conditional statement in ajax function i m tring to describe my problem properly,what i want when i select a value form a combo its vlue is passed...
1
3188
by: Steffen Stellwag | last post by:
Truely is often better to scan a table in full passing by an index , but if you can force the optimizer to use an index via a hint for testing and comparing the results. But the index in the...
2
2687
by: Peted | last post by:
im using c# vs2008 is it possible to define two partial classes in two different named code modules in this case the class and its attched designer class, and have a using statement at the top...
1
1621
by: smartic | last post by:
I need to use this string "preg_match('$pattern','$value')" to return boolean value in if statment how can i do that i used eval function put it give me this error (Parse error: syntax error,...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.