VB.NET Module - Can I force the use of .Public_Member_Name when accessing pub. Members?

后端 未结 3 565
有刺的猬
有刺的猬 2020-12-21 23:54

I have a situation where I have several VB.NET Modules in the same Logical-Module of a large application.

I would like the update function of each module to be publ

相关标签:
3条回答
  • 2020-12-22 00:05

    Using modules is usually a poor design. Consider replacing them with Classes. A module in VB.NET is simply a static class. In other words it doesn't have to be instanced and you can call module.function. When you replace your modules with classes you will need to instance them. Then you can call class_instance.update with ease.

    0 讨论(0)
  • 2020-12-22 00:19

    Yes, it is possible, if you are willing to wrap the module within a namespace of the same name as the module:

        Namespace ModuleName
            Module ModuleName
            ...
            End Module
        End Namespace
    
    0 讨论(0)
  • 2020-12-22 00:28

    No.

    The VB.NET specifications automatically use Type Promotion to allow this behavior to occur. The only way to avoid this is to have a type at the namespace that has the same name (Update) which would prevent (defeat) the type promotion provided in VB.NET.

    0 讨论(0)
提交回复
热议问题