top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Is there a difference between "using System.Data;" and directly adding the reference from "Add References Dialog Box"?

+1 vote
403 views
Is there a difference between "using System.Data;" and directly adding the reference from "Add References Dialog Box"?
posted Mar 9, 2014 by Kanika Prashar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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.

answer Mar 9, 2014 by Bhani Bhosle
Similar Questions
+2 votes

I am writing a messaging app in android studio. When I hit the send button it should show me the option to select a sim card if the device has dual sim. If not it should not show the dialog box and should select the default by its own. What should be used for this scenario?

+4 votes

Why returning dataset or data table from WCF service is not a good practice?
What are the alternatives ?

...