Interviews3 answers
3 Answers
using keyword in .net has the following usage:
1. it is used when you want to include a namespace in your current class and use the classes and properties of that namespace without the need to give fully qualified names.
for example: using System;
2. it is used when you want to mark an object to be disposed as soon as it exits the current execution block allowing the garbage collector to collect it.
for example:using (A obj = new A()) {
//some operation goes here
}
This requires the class to implement IDisposable interface.
Renu AgarwalPosted Aug 12, 2016, 4:34 AM EDT
A using declaration provides access to a specific namespace member. This is accomplished by applying the using keyword to a namespace name with its corresponding namespace member.
Keerthi VenkatesanPosted May 18, 2016, 1:54 AM EDT
A using declaration makes it possible to use a name from a namespace without the scope operator..
shubhaPosted Jul 12, 2006, 8:43 PM EDT

