What is the difference between "using System.Data;" and directly adding the reference from "Add References Dialog Box"?

When u compile a program using command line, u add the references using /r switch. When you compile a program using Visual Studio, it adds those references to our assembly, which are added using "Add Reference" dialog box. While "using" statement facilitates us to use classes without using their fully qualified names.
For example: if u have added a reference to "System.Data.SqlClient" using "Add Reference" dialog box then u can use SqlConnection class like this: System.Data.SqlClient.SqlConnection
But if u add a "using System.Data.SqlClient" statement at the start of ur code then u can directly use SqlConnection class.
On the other hand if u add a reference using "using System.Data.SqlClient" statement, but don't add it using "Add Reference" dialog box, Visual Studio will give error message while we compile the program.

Showing Answers 1 - 1 of 1 Answers

samiksc

  • Jan 16th, 2006
 

  1. The library which you want to use in your code must have a reference added using 'add reference'.
  2. The 'using ..' statement allows you to call methods in the namespace directly without using the fully qualified name like <namespace name>.<method name>

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions