Namespace references in C# vs. VB.Net

后端 未结 3 1436
轮回少年
轮回少年 2021-01-04 21:55

In VB.Net you can do something like the following without any issues... just ignore the fact that this is a pretty useless class :-)


Imports System

Public          


        
3条回答
  •  被撕碎了的回忆
    2021-01-04 22:31

    using directive in C# does not allow this:

    Create a using directive to use the types in a namespace without having to specify the namespace. A using directive does not give you access to any namespaces that are nested in the namespace you specify.

    VB.NET, however, supports somewhat closer behavior with Imports statement:

    The scope of the elements made available by an Imports statement depends on how specific you are when using the Imports statement. For example, if only a namespace is specified, all uniquely named members of that namespace, and members of modules within that namespace, are available without qualification. If both a namespace and the name of an element of that namespace are specified, only the members of that element are available without qualification.

    Reference SO Question

提交回复
热议问题