Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8558341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:47:23+00:00 2026-06-11T15:47:23+00:00

In C# we write using System.IO or any other namespace we want to use.

  • 0

In C# we write using System.IO or any other namespace we want to use.

So is it a bad habit, does it affect performance or memory?

Or is it good to create wrapper classes for them and use it to avoid using the same namespace everywhere?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:47:24+00:00Added an answer on June 11, 2026 at 3:47 pm

    In .Net, the namespace is always an integral part of the name of each type.
    However, if you had to specify the entire namespace each time you are declaring a certain type it would have caused tremendous repetition and noise in the code. This is what the using directive is for, it essentially folds all the prefixes into one place, making you specify the “last” section of a type. This can be done only in case there are no ambiguities.

    The compiler however, doesn’t care about the above. So there exists a pre-compilation stage where each type declaration that relies on a using directive gets its prefix back.

    So when you say:

    Using System;
    
    void foo()
    {
       String s1 = "bla";
       String s2 = "bli";
    }
    

    What happens in pre-compilation is that the is appending the System namespace to each String declaration, like this:

    void foo()
    {
       System.String s1 = "bla";
       System.String s2 = "bli";
    }
    

    And only now the compiler really kicks in.

    So about the performance, technically, it can effect performance of the build process. The more usings you have, the more matching needs to be done in the pre-compilation stage: so the compiler sees String. What String is that? Is it System.String or is it SomeOtherNamespace.String? What really happens is that the compiler appends each namespace it finds in using to the type declaration and checks whether such a type exists. If yes- great, if no- it trys the next namespace.

    So you see, in case you have many files with unused using declarations, the compiler necessarily does redundant work. In extreme cases, it can significantly degrade the performance of the build itself.

    In general, never hesitate Using something that you are using (no pun intended). But you should avoid declaring unnecessary using directives, not just because of the potential (unlikely) performance impact on the build duration but also because you want to keep your code as clean as possible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using System; using System.Math; class test { public static void Main() { Console.Write(Enter any
I'm trying to write bytes using the write() Unix system call, but any 8-bit
In C#, how many classes can you inherit from? When you write: using System.Web.UI;
I'm trying to write Unicode characters (♠) using System.out , and a question mark
Is there significant problem, if I write the code for embedded linux system using
I'm trying to write a drop-in replacement for System.Media.SoundPlayer using the waveOut... API. This
I'm using System V Shared Memory to communicate between my two PHP applications. One
Does anyone know of any good tools/utilities for managing Web.Config files between different build/deployment
Let's say I have a buggy application like this: using System; namespace ConsoleApplication1 {
Here I wrote a C program which executes hi.sh file using system call. Here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.