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 948195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:12:14+00:00 2026-05-15T23:12:14+00:00

Assuming namespace A2 is nested within namespace A1 , then A2 is a member

  • 0

Assuming namespace A2 is nested within namespace A1, then A2 is a member of enclosing A1. But members of A2 ( thus types declared within A2 ) are not members of A1.

a) What exactly is meant by members of A2 not being members of A1? In other words, what would be different if they were also members of A1? Perhaps that inside A1 we wouldn’t have to use fully qualified name for types in defined in A2?

b) What exactly is it meant by namespace A2 being a member of A1?

BTW – I do understand namespaces, I’m just confused by the terminology used by my book ( namely, A2 being a member of A1 etc )

thanx

EDIT

1) So essentially A2 being a member of A1 is the reason why inside A1 we don’t have to specify A1. prefix when referencing types declared in A2:

namespace A1
{
    class Program
    {
        static void Main(string[] args)
        {
            A2.classA2 a2= A2.classA2(); //here we don't need to include A1.
                                           prefix
        }
    }

    namespace A2
    {
       class classA2 { }
    }
}

2) The following is defined within assembly asmLibrary.dll

namespace A
{
    public class A1{}


    namespace B
    {
        public class B1{}
    }
}

The following application App1 also has a reference to assembly asmLibrary.dll:

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            B.B1 instanceB1 = new B.B1();
        }
    }
}

The following application App2 has a reference to assembly asmLibrary.dll:

using A;
namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            A.B.B1 bInstance = new A.B.B1(); 

            A1 a1 = new A1();
        }
    }
}

a) When we tried to declare in App2 an instance of A.B.B1, we needed to specify fully qualified name of the type. But with App1 we were allowed to specify the type via B.B1. Thus why were we allowed to ommit the A. prefix inside App1, but not inside App2 ( App2 has a using A; directive, so its behaviour should be identical to that of App1 )?

b) Also, if namespace B is a member of namespace A, shouldn’t then App2 allow us to declare a type A.B.B1 using B.B1 instanceB1 = new B.B1(); syntax?!

  • 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-05-15T23:12:15+00:00Added an answer on May 15, 2026 at 11:12 pm

    Consider the following

    namespace A1
    {
        namespace A2  // A1.A2
        {
            class C2  // full name: A1.A2.C2
            {
                private A1.C1 c1b;   // full name 
                private C1 c1b;      // shortest form. A1 is in scope here
            }
        }
    
        class C1   // full name: A1.C1
        {
            private A1.A2.C2 c2a;   // full name
            private A2.C2 c2b;      // shortest form. We can omit the A1 prefix but not A2
        }
    }
    

    Answers

    a) the class C2 is not a (direct) member of A1, so outside of the A2 namespace we have to declare
    it as A2.C2 c2b;

    b) The members of A1 are in scope inside A2, see the declaration of C1 c1b;


    Re the Edit:

    Your example shows the different effects of using a; ... and namespace A { ... }.

    The using statements ‘imports the types from A (§ 16.3.2)‘ while in App2 the code is inside the namespace.
    The term ‘member’ can be a bit confusing here.

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

Sidebar

Related Questions

Assuming a class called Bar in a namespace called foo , which syntax do
Assuming such a query exists, I would greatly appreciate the help. I'm trying to
Assuming you can't use LINQ for whatever reason, is it a better practice to
Assuming there are 5 items in the settings file ( MySetting1 to MySetting5 ),
Assuming network access is sporadic with no central server, what would be the best
Assuming I have only the class name of a generic as a string in
Assuming I have an open source web server or proxy I can enhance, let's
Assuming String a and b: a += b a = a.concat(b) Under the hood,
Assuming I'm trying to automate the installation of something on windows and I want
Assuming I have three tables : TableA (key, value) TableB (key, value) TableC (key,

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.