Namespaces and subnamespaces in C#

前端 未结 8 996
鱼传尺愫
鱼传尺愫 2021-01-19 07:23

begginers question about C#.

In every program I have to include several namespaces, like:

using System;
using System.Collections.Generic;
using Syste         


        
8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-19 07:37

    System and System.Text are two different namespaces. That System.Text seems to be a part of System is the semantics we as programmer put into it. There's no such thing as a nested namespace from a platform view;

    But even if that was not the case what should happen if you had

    namespace MySystem{
       namespace Foo{
           class Bar {...}
       }
    
       class Bar{...}
    }
    
    using MySystem;
    class MyClass{
        private Bar _myBar; //Which one is it MySystem.Foo.Bar or MySystem.Bar?     
    }
    

提交回复
热议问题