VB.NET:如何引用 VB.NET 模块? [英] VB.NET: How to reference VB.NET module?

查看:48
本文介绍了VB.NET:如何引用 VB.NET 模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了一个实用模块,因为 VB.NET 没有像这样的静态类C# 和 Module 是 VB.NET 中的静态类.之所以使用module,是因为我使用的是Extension方法,只能在Module中使用.

I got a Utility module since VB.NET doesn't have static class like C# and Module is the static class in VB.NET. The reason that I use module is because I'm using the Extension method and it can only be use in Module.

我不能引用这个模块,但如果我把我的代码放在一个类中.我可以毫无问题地参考它.可能是什么原因?我错过了 C#.

I can't reference to this module but if I put my code in a class. I can reference to it without any problem. What could be the reason? I missed C#.

该模块位于类库调用 Utility 中.

The module is inside a class library call Utility.

推荐答案

我不能引用这个模块,但如果我把我的代码放在一个类中.我可以毫无问题地参考它.有谁知道为什么?

I can't reference to this module but if i put my code in a class. I can reference to it without any problem. Does anyone know why?

因为 VB 中的模块不是类,不能用于实例化对象.相反,它们类似于命名空间,不同之处在于命名空间不能直接包含函数.所以模块的原因是提供一种方法来对不属于类的函数进行逻辑分组.

Because Modules in VB aren't classes and can't be used to instantiate objects. Rather, they're something similar to namespaces, with the difference that namespaces can't contain functions directly. So the reason for modules is to provide a way to group functions logically that don't belong to a class.

当您考虑到并非所有逻辑上都属于一个类时,这很有意义.考虑 System.Math.除了奇怪的 OOP 纯粹主义之外,绝对没有理由将其作为一个类.

This makes a lot of sense when you consider that not everything logically belongs to a class. Consider System.Math. There is absolutely no reason to make that a class, other than a weird OOP purism.

顺便说一句,你也不能在 C# 中引用静态类,至少如果我正确理解你所说的引用"是什么意思的话.也许你可以澄清这一点.

By the way, you can't reference static classes in C# either, at least not if I understand correctly what you mean by "reference". Perhaps you can clarify this.

这篇关于VB.NET:如何引用 VB.NET 模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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