Use the using operator in C #

Source: Internet
Author: User

Isn't the using operator in C # used by many people? Don't even know?
In fact, this operator is very useful in small places.

String 8

 

According to the msdn explanation
Http://msdn2.microsoft.com/zh-CN/library/yh598w02 (vs.80). aspx
The using keyword is also used to create using statements. This type of statement defines when the object string 8 will be released.

For example
Class Demo: idisposable
{
Public void dispose ()
{
Console. writeline ("dispose ");
} String 6

Public void demomethod ()
{
Console. writeline ("hi ");
}
}; String 9

Using (demo a = new demo ())
{
A. demomethod ();
}
We can see that the dispose () method will be executed at the same time, which makes the convenience self-evident.

String 4

 

For more information, see sqlhelper. CS in petshop 4.0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.