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

  • Home
  • SEARCH
  • 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 8741403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:18:29+00:00 2026-06-13T11:18:29+00:00

I have a static class like so: namespace Engine.Configuration { public static class Configuration

  • 0

I have a static class like so:

namespace Engine.Configuration
{
    public static class Configuration
    {
        public static int i;
    }
} 

In the same project, but a different namespace I have a class trying to access the static class variable:

namespace Engine.MainProgram
{
    public class MainProgram
    {
        int x;
        int y;
        public void LoadConfiguration()
        {
            x = Configuration.Configuration.i;
        }
    }
}

What I would like to do is just place a using statement in MainProgram like so:

using Engine.Configuration;
...
x = Configuration.i;

But when I try to visual studio always treats Configuration as a namespace instead of the static class. My question is why does this happen and how do I correct this?

  • 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-13T11:18:31+00:00Added an answer on June 13, 2026 at 11:18 am

    The compiler doesn’t always know how to distinguish between a namespace and a class name with the same name.

    Change this:

    using Engine.Configuration;
    

    To a namespace alias:

    using Configuration = Engine.Configuration.Configuration;
    

    Explenation:

    Let’s say you are working directly under the root namespace, Engine, like so:

    namespace Engine
    {
    }
    

    Then you could get things in other namespaces like this:

    namespace Engine
    {
        Engine.Configuration.Configuration;
    
        // Or since you are in the root (Engine) you don't need to specify Engine:
        // You can always omit the root namespace if the namespace you're in has the same root.
        Configuration.Configuration;
    }
    

    Or by declaring a using for the namespace, but the compiler won’t know if you mean the namespace or the class in the namespace:

    using Engine.Configuration;
    
    namespace Engine
    {
        // This will still work.
        Engine.Configuration.Configuration;
    
        // This will break, do we mean "Engine.Configuration.Configuration" or "Engine.Configuration"?
        Configuration;
    }
    

    So it’s a good practice to never have the same name for a class as the namespace it lives in. Maybe change the namespace to Engine.Configurations.

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

Sidebar

Related Questions

I have a web project like: namespace Web { public partial class _Default :
I have a static class that looks like this: namespace Argus { static class
If I have something like class Base { static int staticVar; } class DerivedA
I have created my own Attached Property like this: public static class LabelExtension {
I have this small class looking like this: private static int field1 = -
I have a program like this - import weka.core.stemmers.SnowballStemmer; public class TestProject{ public static
I have a class like this: public class Stretcher : Panel { public static
I have a class like this: public static class MyFeedExtensions { private readonly static
I have a little console C# program like Class Program { static void main(string
I have a relationship like this class Foo { static hasMany = [bars: Bar,

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.