Difference between using directive vs using statement?
Answer / Anesh Kumar
Using Directives and Using Statements are used in C# to import namespaces, but they have slightly different purposes.nn1. Using Directive:nA using directive imports a namespace at the top of your code file, allowing you to use classes from that namespace without writing the fully qualified name. It creates an alias for the namespace and makes the classes accessible within the scope of the file.nnexample: using System; // imports the System namespacenn2. Using Statement:nA using statement releases the resources acquired by an object when it goes out of scope. This is particularly useful with IDisposable objects, such as those implementing the IDbConnection interface. It creates a disposable object and uses it within the braces, ensuring that the object is disposed of properly after use.nnexample: using (var connection = new SqlConnection(connectionString)) {n // Use the connection object heren}nnIn summary, Using Directives are used for importing namespaces, while Using Statements are used for managing resources.
| Is This Answer Correct ? | 0 Yes | 0 No |
Can you explain the basic use of dataview?
Difference between abstract factory pattern and factory method pattern in .NET with example.
3 Answers ACS, IBM, Keane India Ltd,
What is data control in asp.net?
what is diffgram ?
If i have 1000 records in dataset, how to do paging?
What are Authentication mechanisms in .Net?
what is a virtual class?
What is use of <% %> in asp.net?
How can you register a custom server control to a web page?
write six HTTP request method?
Types of optimization and name a few and how do u do?
What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)