C# Using Statement

In this article i am explaining about using statement in c#.The using statement is usually used once you ought to one or a lot of resources during a section. The victimisation statement obtains one or numerous resources, executes them so releases the objects or resources. it’s wide used in information property through C#.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Using_Statement_Example
{
    class UsingExample : IDisposable
    {
        public void Dispose()
        {
            Console.WriteLine("Execute  Second");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            using (UsingExample obj = new UsingExample())
            {
                Console.WriteLine("Executes First");
            }
            Console.WriteLine("Execute Third");
            Console.ReadLine();
        }
    }
}

Leave a Reply

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