模块VB.Net中的命名空间(Namespace in module VB.Net)

我想知道是否有任何方法可以将命名空间(或类似的东西)放入模块中,仅用于代码排序,如下所示:

Public Module1

    Namespace N1 (or whatever)

        Public N1_1 as integer = 45    

    End Namespace

    Namespace N2 (or whatever)

        Public N2_1 as integer = 28

    End Namespace


End Module

那么我可以这样做:

Module1.N1.N1_1

谢谢!

编辑:值必须能够更改,所以我不能使用枚举


I would like to know if there is any way to make a namespace (or something like that) into a module, is just for code sorting, something like this:

Public Module1

    Namespace N1 (or whatever)

        Public N1_1 as integer = 45    

    End Namespace

    Namespace N2 (or whatever)

        Public N2_1 as integer = 28

    End Namespace


End Module

So then I can do:

Module1.N1.N1_1

Thanks!

Edit: values must be able to be changed so I can't use Enum

2022-12-04 13:12

满意答案

您需要将多个类包装到命名空间中。

那么您的类只有共享成员/属性。

像这样的东西:

Namespace Module1
    Class N1 (or whatever)
        Public Shared N1_1 as integer = 45    
    End Class

    Class N2 (or whatever)
        Public Shared N2_1 as integer = 28
    End Class
End Namespace

You need to wrap multiple classes into a namespace instead.

Your classes would then only have Shared members / properties.

Something like this:

Namespace Module1
    Class N1 (or whatever)
        Public Shared N1_1 as integer = 45    
    End Class

    Class N2 (or whatever)
        Public Shared N2_1 as integer = 28
    End Class
End Namespace

相关问答

更多

asp.net (vb.net)怎样调用Module文件?

直接去添加引用~然后去调用就可以了

vb.net那里下载

官方下载地址:http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-basic-express 此为:vb.net express版本,没有时间限制

vb.net 教程

http://msdn.microsoft.com/zh-cn/library/2x7h1hfk.aspx 微软官方MSDN是最权威的初学场所

模块VB.Net中的命名空间(Namespace in module VB.Net)

您需要将多个类包装到命名空间中。 那么您的类只有共享成员/属性。 像这样的东西: Namespace Module1 Class N1 (or whatever) Public Shared N1_1 as integer = 45 End Class Class N2 (or whatever) Public Shared N2_1 as integer = 28 End Class End Namespace You ...

如何使用VB.net创建Web模块?(How to create web modules using VB.net?)

它们被称为Class文件。 右键单击要添加类的解决方案或文件夹,然后选择“ Add new item然后从窗口中选择“ Class 。 They are called Class files. Right-click on your solution, or folder you wish to add the class and choose Add new item then from the window choose Class.

模块中的Vb.Net设置连接(Vb.Net setting connection in Module)

“Main()”是一个功能。 并且您声明了一个局部变量“sConnection”。 您的表格是另一个类。 类只能访问其成员,全局成员或全局静态成员(或某些朋友方案,如C ++)。 从“Main”中取出声明,在表单范围内声明或将其声明为全局变量,表单可以访问。 或者将您的连接字符串放在配置文件中并从中读取。 (在以后的时间点很容易配置。) The "Main()" is a function. And you declared a local variable "sConnection". Your...

如何在VB.Net中运行Powershell脚本(How to run Powershell scripts in VB.Net)

您可以在VB中运行powershell脚本,请查看以下链接 http://blogs.msdn.com/b/zainnab/archive/2008/07/26/calling-a-powershell-script-from-your-net-code.aspx 上面发布的链接将逐步指导您如何完成此任务。 查看与您相关的问题: 在.NET Windows应用程序中运行powershell脚本 以下文章在C#中,但应该可以帮助您更好地理解这个概念: http://www.codeproject.c...

在Roslyn VB.NET中缺少我的命名空间(Missing My namespace in Roslyn VB.NET)

如果我理解正确的是什么,则通过自动将文件VbMyTemplateText.vb到每个编译中来添加My命名空间。 为了使它实际生成一些东西,必须正确设置预处理器符号_MYTYPE (在控制台应用程序的情况下为"Console" )。 要使这项工作,你还需要引用System.dll ,但之后一切正常: Imports System.CodeDom.Compiler Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.VisualB...

VB.Net模块行为(VB.Net module behavior)

Module在技术上并不意味着静态类。 VB.net中的静态(关于函数)是Shared ,并且没有Shared Class 。 我认为你想要的是一个带有静态/共享函数的密封/抽象/不可继承的类(你可以在没有父类实例的情况下调用函数,但是你仍然需要引用父类。调用函数)。 如果是这种情况,那么执行类似以下的操作: Public NotInheritable Class HelperA Public Shared Function FunctionA() as Boolean R...

将VB.net模块转换为C#(convert VB.net Module to C#)

您可以将常量放在public static class如下所示: public static class MyConnectionStringConstants { public const string strDatabase = "****"; public const string strUserID = "****"; public const string strPssWd = "****"; } 要使用它,您需要像这样引用常量: string strAcces...

相关文章

更多

8 个最棒的 .NET 开发相关工具

本文向你介绍 8 款跟 .NET 开发相关的一些工具。 1)Open Source – Sharp D ...

国外NET 空间免费申请使用

最近研究微信公众帐号接口开发,需要使用到域名和空间,所以在度娘和谷哥的帮助下找到国外免费的空间, 刚刚 ...

【转载】Lucence.Net

搜索引擎学习笔记之Lucence.Net 整理中...[转载] 一、简介 Lucence ...

Good .net tools

SYS-CON Media系列媒体揭晓   2003年度读者选择奖 最佳 .NET 图书暨培训软件 大 ...

storm-project.net

http://storm-project.net/ https://github.com/nathan ...

使用.net调用Solr

1. using System; using System.Collections.Generic; ...

微信开发之.Net

撸主是一个新手,最近几天在研究微信服务号交互,上网搜了搜C#的代码,再结合自己的习惯,下面把代码解析一 ...

github(git.oschina.net)中的 README.md内容换行

不管是github,还是oschina的README.md文件,如果你输入内容直接回车,push到远程 ...

Full-Text Search in ASP.NET using Lucene.NET

This post is about the full-text search engine ...

.net 如何从别的网站获取自己想要的数据

.net 如何从别的网站获取自己想要的数据

最新问答

更多

Python / IPython奇怪的不可重现列表索引超出范围错误(Python/IPython strange non reproducible list index out of range error)

你得到IndexError的原因是你的输入文件显然不是完全用制表符分隔的。 这就是为什么当您尝试访问它时, splits[1]没有任何内容。 您的代码可以使用一些重构。 首先,你正在重复使用if -checks,这是不必要的。 这只是将cds0到7个字符,这可能不是你想要的。 我将以下内容放在一起,以演示如何重构您的代码,使其变得更加pythonic和干燥。 我无法保证它能够与您的数据集一起使用,但我希望它可以帮助您了解如何以不同的方式执行操作。 to_sort = [] # W

故事板从表格单元中延伸出来并显示其详细信息披露按钮(storyboard segue from a tablecell an its Detail Disclosure Button)

我不认为你可以链接一个特定的细节披露按钮瓦特/赛格。 我的故事板是非常程序化的B / C我使用了很多定制CGRect等。 所以我倾向于使用这样的东西: -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { [self performSegueWithIdentifier:@"ViewControllerIdentifer"

我们可以将Gherkin功能文件与testcomplete集成(Can we integrate Gherkin feature files with testcomplete)

TestComplete不支持Gherkin功能文件。 但是,TestComplete具有SDK,因此可以自己为此创建扩展。 TestComplete does not support Gherkin feature files. However, TestComplete has SDK so it is possible to create an extension for this by yourself.

TrustAllCertificatesCallback被忽略(TrustAllCertificatesCallback is ignored)

我没有做过这样的事情,但看看我认为可以看出错误的例子。 试试这个代码: static class Program { static void Main() { var tcpclient = new TcpClient("remote.example.com", 443); var tcpstream = tcpclient.GetStream(); var sslstream = new SslStream(tcpstream,

返回嵌套元素的索引(Return index of nested element)

您需要获取父li元素的索引。 否则,您将获得列表项内锚点的索引,该索引始终为零。 $(this.parentNode).index(); You need to get the index of the parent li element. Otherwise you are getting the index of the anchor inside the list item, which will always be zero. $(this.parentNode).index();

在数组中重新编号元素的有效方法(Efficient way of re-numbering elements in an array)

您需要多次迭代列表,我认为没有办法解决这个问题。 毕竟,在开始更改元素(第二遍)之前,首先必须确定不同元素的数量(第一遍)。 但是请注意,由于对index的重复调用而not in列表中具有O(n),因此可能具有最多O(n ^ 2)的不同元素的数量。 或者,您可以使用dict而不是value_map的list 。 字典比列表具有更快的查找速度,因此,复杂性应该确实在O(n)的数量级上。 您可以使用(1)字典理解来确定旧值到新值的映射,以及(2)用于创建更新子项的列表理解。 value_map =

Express app定义的`static`文件夹无法正常工作(Express app defined `static` folder not working properly)

选项1 你可以改变这一行: app.use( express.static(__dirname + '/puplic')); //my public folder. 至 app.use('/oneTime', express.static(__dirname + '/puplic')); //my public folder 选项2 我假设你在公共文件夹中有一个js文件夹,然后你需要更改你的HTML代码:

使用node.js和socket.io每秒广播一次(Using node.js and socket.io to broadcast every second)

对于计时器值,请在服务器端本身每秒更新本地计时器。 每当有任何用户进来时,给他这个值以及计时器的总值。 然后客户端将根据dandavis评论在本地启动自己的计时器,但在服务器端保留一些间隔,如15或10秒,服务器将广播当前计时器值,以便客户端相应地进行同步。 简而言之,服务器将每隔10(n:你决定)秒后广播,但它将在本地每秒更新定时器变量。 每当客户端进入时,它将获得总计时器值和当前计时器值。 广播当前出价的休息功能可以以正常方式完成。 For timer value, keep updatin

如何让XMLSerializer将命名空间添加到嵌套对象中的属性?(How do I get the XMLSerializer to add namespaces to attributes in nested objects?)

IXmlSerializable也许? 注意我还添加了(对A ): [XmlElement("A", Namespace = "http://www.example.com/namespace")] public TestSoapHeaderTypeValuePair A {...} 代码如下: public class TestSoapHeaderTypeValuePair : IXmlSerializable { private string _type; private