Home > Net > C # namespace and scope of some question
C # namespace and scope of some question
Time:09-20
using System; using System.Collections.Generic; Using System. The Text;
The namespace ConsoleApp1 { Class A {
}
The namespace Controllers { The class Con {
}
The namespace Api { The class Test { ApiB. Test1 Test1=new ApiB. Test1 ();//here why can access to the ApiB space??????? } }
The namespace ApiB { The class Test1 { Models. Mo Mo=new Models. Mo (); Why can access to the Models of space//here??????? } } }
The namespace Models { The class Mo {
}
The namespace Entity { The class Song {
} } } }
My understanding of the namespace is similar to the concept of computer file directory, the above Test class in ConsoleApp1. Controllers. In the Api, why can access to the ApiB (ConsoleApp1. Controllers. ApiB)?
Another is by the same token, the Test1 class in ConsoleApp1. Controllers. The ApiB, why can access to Models (ConsoleApp1. Models) the contents of the
If I can understand is to write a fully qualified, similar to the absolute path; But the above this kind of not fully qualified to write a bit like a relative path to write, but don't like the feeling of relative paths, reasoning, guidance, thank you
CodePudding user response:
Models. Mo, bring namespace can Or using Models; So Mo directly, omit Models, can also