有没有办法逃避的根命名空间在VB? [英] Is there a way to escape root namespace in VB?

查看:123
本文介绍了有没有办法逃避的根命名空间在VB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 命名空间的ConsoleApplication1 
{
类节目
{
静态无效的主要(字串[] args)
{
System.Text.MyCustom MC =新System.Text.MyCustom();
}
}
}

命名空间System.Text
{
公共类MyCustom {}
}

我如何做到这一点在VB中,虽然具有在应用程序根命名空间,这可能吗?



更新
根据我以为不过是没有办法做到这一点的答案。
我贴功能建议微软连接: 请投票


解决方案

在VB.NET VS 2012的这个老问题得到解决。这个版本开始,你能逃脱与一家领先的全球根命名空间。下面的代码是在VS 2010中缺陷和纠正在VS 2012:



<预类=朗动prettyprint-覆盖> 导入工具

模块模块1
子的Main()
的SayHello()
端子
端模块

命名空间Global.Tools
模块TestModule
子的SayHello()
Console.Out.WriteLine(你好)
端子
端模块
端命名空间


namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Text.MyCustom mc = new System.Text.MyCustom();  
        }
    }
}

namespace System.Text
{
    public class MyCustom { }
}

How do I do this in VB, while having a root namespace in the application, is this possible?

Update: According to the answers I assume there ain't no way to do this. I posted a feature suggestion to Microsoft Connect: Please vote.

解决方案

In VB.NET of VS 2012 this old problem is fixed. Beginning with this version you can escape the root namespace with a leading global. The following code is buggy in VS 2010 and correct in VS 2012:

Imports Tools

Module Module1
    Sub Main()
        SayHello()
    End Sub
End Module

Namespace Global.Tools
    Module TestModule
        Sub SayHello()
            Console.Out.WriteLine("Hello")
        End Sub
    End Module
End Namespace

这篇关于有没有办法逃避的根命名空间在VB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆