在哪里保存结构:类、模块还是无?
这纯粹是一个有关 VB.NET 结构的编码练习问题。你在哪里放一个?
举个例子,我创建了一个结构,其简单目的是保持信息井井有条,我希望这个结构是独立的,不属于任何类,这样我就不必通过 SomeClass 访问它.MyStructure 而只是 MyStructure
。那么,我是否将其保存在一个单独的类中并将其导入到我的命名空间中?我是否将其保留在模块中(本质上是静态类)?我是否只需创建一个单独的 VB.NET 代码文件并放置在那里(我希望希望它位于单独的文件中)。只是为了澄清,我需要整个应用程序访问此结构,而不仅仅是单个类。
遇到这种情况你通常会怎么做?
This is purely a coding practice question concerning VB.NET structures. Where do you keep one?
As an example, I've created a structure for the simple purpose of keeping information organized, I'd like this structure to be stand-alone, not belonging to any class so I wouldn't have to access it through SomeClass.MyStructure
but rather simply MyStructure
. So, do I keep it in a separate class and import it into my namespace? Do I keep it in a module (Static class, essentially)? Do I just make a separate VB.NET code file and place is there (I would like it to live in a separate file). Just to clarify, I need this structure to be accesses by the whole application, not just a single class.
What do you usually do in such cases?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
结构是一种类型,很像类。
所以是的,把它放在一个单独的文件中。然后它将位于“命名空间中”,即项目默认的命名空间。
A structure is a Type, much like a Class.
So Yes, put it in a separate file. Then it will be 'in a namespace', the project-default one.