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#.
class check_using : IDisposable
public void Dispose()
static void Main(string args)
using (check_using c = new check_using())
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.
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#.