LEARN BUILD GROW TOGETHER
Practical knowledge for developers
DEVELOPER LEARNING HUB
Learn. Build. Grow Together.

Practical tutorials, real-world examples and interview preparation.

.NETC#SQL SERVERANGULAR
Home /C# /use of using keyword in C#

use of using keyword in C#

August 7, 2022 5 min read
 


# using keyword:- using keyword has two major uses:-

1.As a statement:-The using statement defines a scope at the end of which an object will be disposed.
Note:- Internally using keyword call the dispose method to dispose the I Disposable interface.

        public List<Student> GetSudent()
        {
            using (DbFirstProjectEntities _context=new DbFirstProjectEntities())
            {
                var students = _context.Students.ToList();
                return students;
            }            
        }


2.As a directive: Using keyword can be used to include a namespace in our program.

    using System.Text;

No comments:

Post a Comment