I
I
Ivan2016-10-09 17:50:38
C++ / C#
Ivan, 2016-10-09 17:50:38

System.io mscorlib or system in C#?

There is a namespace System.IO , it is contained in mscorlib.dll and system.dll. Both .dlls are included automatically when the project is created.
How can I specify in the using System.IO directive that the given namespace should be used from, for example, mscorlib.dll? how is it determined from which .dll to use namespaces?
(the matter is that in mscorlib.dll there is something that is not present in system.dll...).

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Makarov, 2016-10-09
@Iv_and_S

It's not entirely clear why you would. When you write using System.IO, entities from the entire System.IO are added to the current scope, no matter from which assembly (in other words, from all assemblies at once). This is the point of namespaces in dotnet - they are a way of logically dividing a project and libraries (as opposed to physically dividing into assemblies). If you don't want to wire everything, wire a specific class like this:
using StreamReader = System.IO.StreamReader;

G
Georgy Pelageykin, 2016-10-09
@ArXen42

Namespaces are essentially just syntactic sugar (well, a bit of metadata, sort of), for .net they are just prefixes of type names. Those. what looks like MyClass in the MyNamespace namespace is, to the CLR, a type named MyNamespace.MyClass, so MyNamespace.MyClass can be in one assembly and MyNamespace.AnotherClass in another.

R
Roman, 2016-10-09
@yarosroman

https://msdn.microsoft.com/en-us/library/ms173212.aspx
It's normal behavior that namespaces from different assemblies are merged into one, from the link above, this is for if you have matching names in the same space, but different builds. All the same, both are connected, without system.dll it is very difficult to write something. It's just that there is no managed code in mscorlib.dll, this is actually the CLR, more high-level things were simply taken out in system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question