Can excessive "use" reduce performance

Just a performance question ...

Let's say I have 5 classes, and each of them has a link to System.Data and a homegrown library. The 5 classes in question are part of the class library and will eventually be created and published in some web applications as reference information.

Is there any size / performance obtained when using functions that reference System.Data and another library to my own class, so that the number of references to System.Data and my other library is reduced from 5 to 1? Common Sense tells me that it doesn’t matter because the DLLs will be read at the point of one of the functions being executed, so it doesn’t matter where they sit, or how many times you "use System.Data" in your codebase ... but I was wrong earlier:)

+6
source share
1 answer

No - using directives do not add references to assemblies; they import namespaces for code in the same scope. Everything they do allows you to use

 Foo foo = new Foo(); // etc 

in code instead

 Some.Namespace.Containing.Foo foo = new Some.Namespace.Containing.Foo(); 

They do not change which assemblies are referenced at all. It's important to understand different namespaces and assemblies - unfortunately, since they often use the same names, this can be misleading. As an example, where they differ, the Enumerable class in the System.Linq namespace is in the System.Core assembly.

+10
source

Source: https://habr.com/ru/post/901529/


All Articles