Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does adding a reference to csproj file do?

Would it be accurate to say that a given DLL contains a bunch of namespaces (With classes, constants, functions etc. in each), and that referencing the dll in a csproj allows using them in .cs files belonging to that project?

I tried searching the web, but was unable to find answers which satisfied me. (Probably because the question is very basic)

like image 442
yuvalm2 Avatar asked May 10 '17 08:05

yuvalm2


1 Answers

The simple answer to your question is yes.

In order to use an external or a 3rd party component in your IDE, you must first add a reference to it.

Once you added an assembly reference, you will be able to use its methods and properties in your code, by explicitly referring to them:

someNamespace.someClass.someMethod();

Or by using the using statement at the beginning of your code file and simplifying the reference call:

using someNamespace.someClass;

someMethod();

Adding a reference (in Visual Studio)

To add a reference in Visual Studio, right click the "references" folder > choose "add reference" and then "Browse" to you DLL.


Examining existing references

In Visual Studio, in the Project Explorer Pane, you can view the details about a reference (such as the version and its location) by expanding the References folder, right-clicking a reference, and selecting Details.

like image 98
Koby Douek Avatar answered Nov 14 '22 23:11

Koby Douek