Vadzim Savenok Vadzim Savenok - 6 months ago 55
C# Question

How C# handles workload with using statement?

I am currently cleaning up the code for my project and trying to improve its performance. As a part of improvement, I thought of removing unused "using" statements from all files. I would like to figure out if that would indeed improve the performance, so here is my question.

Through the "using" statement, is an external library/resource loaded when any method from the file is executed (READ: When file itself is loaded) OR the external library is loaded only when calling a specific method is actually using this library?


The using statement is purely syntactic sugar; it lets you skip writing the namespace when using types in that namespace.

It has no effect whatsoever on the compiled IL or runtime performance.