A
A
Alexey Lebedev2015-08-25 12:13:01
ASP.NET
Alexey Lebedev, 2015-08-25 12:13:01

Does using in C# affect performance?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

Consider our dispute.
Whether it's worth cleaning it or not, I know that in PHP include should be cleaned if not needed.
Interested in practical use.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
OnYourLips, 2015-08-25
@swanrnd

Whether it's worth cleaning it or not, I know that in PHP include should be cleaned if not needed.
In PHP, you shouldn't use include at all.
Is it worth cleaning it or not
Worth it, leave only those that are used.
But it doesn't affect performance.

S
Stanislav Makarov, 2015-08-25
@Nipheris

The practical benefit is in the readability of the code. When you start reading the source code, you look through the usages and understand what entities they are going to operate with here.
And with regards to performance - you are confusing compilation and interpretation, as well as using as an import of names and include as an insertion of the contents of another file.
The C# compiler will deal with the names used at the compilation stage, so it will either unambiguously match all of them with full names, or it will generate an error. Of course, when fewer names are imported, the compilation will be slightly faster, but this a) does not affect the performance of the compiled assembly; b) much less important than the readability of the code, which will suffer first from 30 usings in one file.
By the way, a large number of using is also a signal of the need to split the source code into several files.

A
Aram Aramyan, 2015-09-24
@GreenBee

1. using in C# does not include any assemblies, unlike PHP include, and therefore cannot affect performance in any way.
2. Install CodeMaid and it will clean up unnecessary uses, spaces, tabs... The only thing to be careful about is that it also removes all unused using, including using System. And at some point you will make edits, and your DateTime is underlined - do not be nervous, but just add using.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question