Namespace references in C# vs. VB.Net

半世苍凉 提交于 2019-11-30 18:44:05
Kirtan

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

This is because VB.Net supports partial namespaces; C# does not.

With Visual Basic, System is imported by default and child namespaces are automatically resolved.

Read more in this article.

VB.Net vs C#, Round 2: Partial Namespaces

you can say System.Collections.Generic.List. that would work.

I think you need to give the entire list and not omit out the system part.

ALso you will need to template it with string as in List similar to the List(Of string)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!