Namespaces and subnamespaces in C#

前端 未结 8 995
鱼传尺愫
鱼传尺愫 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条回答
  •  梦毁少年i
    2021-01-19 07:42

    Imagine these namespaces with these classes (the last name is a class):

    • A.B.Class1
    • A.Class2

    Now you have the following:

    using A - allows you to refer to Class2 directly... but not to Class1.

    using A.B - allows you to refer to Class1 directly but not to Class2.

    If you want to refer to both classes directly in your code, you need both usings.

提交回复
热议问题