473,672 Members | 2,475 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.Stre amWriter varFile = new
System.IO.Strea mWriter("fileNa me")).
Thanks,
RKNET
May 31 '06 #1
2 1246
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.Stre amWriter varFile = new
System.IO.Strea mWriter("fileNa me")).
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.Stre amWriter varFile = new
System.IO.Strea mWriter("fileNa me")).
Thanks,
RKNET

May 31 '06 #3

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

Similar topics

1
1587
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 least...I'm trying to name my columns tablename.fieldname....any help would be appreciated, thanks
1
4687
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 as value from Table sales
9
15706
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
1738
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* to be front-ended on multiple databases as well as rendered in multiple browser types. That being said, is there a pre-constructed class out there that I can call from within my code to systematically "build" my SQL statement and have it take...
5
3212
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 at conventions. I have a main form with two subforms. On the main form, there is a text box that displays the sum of total orders entered in the subform, . I'm trying to create another text box on the main form, that looks at the subtotal...
1
1582
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 work " .mysql_insert_id(); and not any other php or mysql error to tell me if anything is wrong the insert statment. To top it up, I have an echo statment of the insert statment before it executes, when I copy and paste the insert statment from...
1
1356
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 to ajax function and according to the value,i want to visible a <div>.but when i use a if or any conditional statement in ajax function it not woks,and if i remove the conditional statment it works,means my code for div is write.so pls help me if...
1
3209
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 above example is not used , because the hint is malformed, if tables in a Select statment are named by aliases you have to specify the alias name in the hint statment , not the table name /*+ INDEX (ICWOIMP PK_ICWOIMP) */ change to /*+ INDEX (A...
2
2695
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 of the main class that allows access to a 3rd class/control/dll etc etc if i have the using statment at the top of the main class is it possible to have that using statement used in a partial class there, and have the using statment propogate...
1
1632
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, unexpected $end in : eval()'d code on line 1)
0
8487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7449
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6240
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5708
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4230
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2821
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 we have to send another system
2
2064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1819
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.