Harikrishna
Harikrishna

Reputation: 4305

Does Adding more namespace in the code file affect performace?

If we imports more namespace in the code file(cs file) then it affects on perfomance ? Like we should add namespace in the cs file as needed. That is adding more namespace in the cs file affects performance ? Like

using System;
using System.Data.Sql;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using System.Data.SqlClient;
using System.ComponentModel;

Upvotes: 2

Views: 362

Answers (3)

Anthony Pegram
Anthony Pegram

Reputation: 126844

It doesn't affect performance. But for code cleanliness, I would suggest removing using statements that are not needed in a particular class file. It's simple enough, just right-click within the IDE and go to Organize Usings.

Upvotes: 1

Faizan S.
Faizan S.

Reputation: 8644

It doesn't affect your perfomance at all.

Everything is loaded when it's needed. So if you have some statements that are never used, it won't hurt the performance of your application.

Unused statements are mostly cleaned up for clarity and readability of code.

Upvotes: 2

anantmf
anantmf

Reputation: 66

No it will not affect performace. As it is only used by the Compiler.

Upvotes: 0

Related Questions