What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 59104 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > What are the situations we can use "USING" keyword in C# ...
Sivakumar.S

What are the situations we can use "USING" keyword in C#

Replies: 5 | Posted by: Sivakumar.S on 6/5/2012 | Category: C# Forums | Views: 338 | Status: [Member] | Points: 10  


Hi all,

What are the situations we can use "USING" keyword in C#. As per my knowledge we are using to import namespace. Is any other usage for "USING" keyword in C# ?. And also please clear what are the situations we should use "IS" AND "AS" keyword in C#. can anyone explain with detail explanation and its usage?

siva


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Kavi.Sirius
Kavi.Sirius  
Posted on: 6/5/2012 1:07:33 AM
Level: Starter | Status: [Member] | Points: 25

Sivakumar.S, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Ajay.Kalol
Ajay.Kalol  
Posted on: 6/5/2012 1:44:27 AM
Level: Starter | Status: [Member] | Points: 25

Here is Sample Code for Understanding Use of " Using "

using(SqlConnection con= new SqlConnection(connectionString) )
{
SqlCommand cmd = new SqlCommand(commandString, sqlconnection);
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
//DO
}
}
}


"Using" keyword takes the parameter of type IDisposable.
Whenever you are using any IDisposable type object you should use the "using" keyword to handle automatically when it should close or dispose.
Internally using keyword calls the Dispose() method to dispose the IDisposable object.
Object is disposed automatically on the end of this statement.

For is and as operator
it is use for check casting and return Boolean value.
check for more details
http://ekrishnakumar.wordpress.com/2006/07/08/c-is-and-as-operators/

http://ajaypatelfromsanthal.blogspot.in

Sivakumar.S, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Sivakumar.S
Sivakumar.S  
Posted on: 6/5/2012 3:36:36 AM
Level: Starter | Status: [Member] | Points: 25

Hi all,

Thanks for your explanations.




siva

Sivakumar.S, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Perfect.Chourasia@Gmail.Com
Perfect.Chourasia@Gmail.Com  
Posted on: 6/7/2012 6:19:25 AM
Level: Starter | Status: [Member] | Points: 25

"Using" keyword takes the parameter of type IDisposable.

After using it dispose the connection by default 25 connection are allowed in Dot.net

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://sandeep-chourasia.blogspot.com/

Sivakumar.S, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Muhsinathk
Muhsinathk  
Posted on: 6/11/2012 2:33:47 AM
Level: Bronze | Status: [Member] | Points: 25

Sivakumar.S, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/23/2013 2:51:17 PM