C# Using Statement

using-statements
In this chapter you will learn:

  • What is Using Statement in C#?
  • What is the functionality of Using Statement in C#?
  • How to use Using Statement in C# programming?

The using statement is mostly used when you need to one or more resources in a segment. The using statement obtains one or various resources, executes them and then releases the objects or resources. It is widely used in database connectivity through C#.

Example:





  • In the above example, the using statement calling the check_using class to execute. So, it first executes the using block, then executes the check_using class and finally executes the last statements.

    Output

    Executes First
    Execute Second
    Execute Third
    __

    Summary

    In this chapter you learned what Using Statement is and how to use it in C# programming. In next chapter you will learn about Enumeration in C#.


    Leave a Reply

    Your email address will not be published. Required fields are marked *