Why don't I need to reference "System.dll" in order to use the "System" namespace?

I am working on an assignment that says "Do not use external libraries." So I created a C # application, and the first thing I did was remove all the dll links by default ... including "System.dll".

However, I can add this to my code:

using System; using System.IO; 

I was just curious to know why I do not need to have System.dll as a link in my project to do this. Thanks!

+8
c # visual-studio-2010
source share
5 answers

mscorlib.dll includes elements in both namespaces.

To remove this link, right-click the project> Properties> Build> Advanced ... and check the box "Do not link to mscorlib.dll".

+10
source share

Different assemblies can contribute to the same namespace.

Even if you don't reference System.dll, you still reference (implicitly) mscorlib.dll, which introduces many types to the System namespace.

+2
source share

These links are probably defined in your Web.config or Machine.config file, so they are enabled by default.

0
source share

These are the default libraries. I think your question is "dont use third party dlls"

0
source share

Another thing to consider is that if you compile directly through the command line, the default key set, including links to the default libraries, is analyzed by the compiler through the default answer file (csc.rsp) located in the same directory as the compiler. The fact that you can import namespaces from the base class library without explicitly referencing them at compile time is because their containing assemblies are included in your program by default. To change this behavior on the command line, you can use the / nostdlib switch so that it does not include mscorlib.dll, or you can use / noconfig so that it completely ignores the entire default answer file. Also, I'm not sure what you mean by system .dll because the namespaces mentioned are contained in the mscorlib.dll file. In addition, I think that the "external library", your instructor should have understood any third-party assemblies that will help you in solving the problem. Everything that is included in the .NET SDK will most likely be part of the library. If your teacher is really harsh and wants you to invent the wheel: P

0
source share

All Articles