简体   繁体   English

VB.NET等效于C#接口用法作为参数

[英]VB.NET equivalent of C# interface usage as parameter

EDIT 2: 编辑2:

Right I thought it was a problem with my syntax, so I tried to explain the situation using a simple interface. 是的,我认为这是我的语法有问题,所以我尝试使用一个简单的界面来解释这种情况。 The real situation is this: 实际情况是这样的:

I have created an interface called IRepeatingTransaction in a module called ModGlobal: 我在名为ModGlobal的模块中创建了一个名为IRepeatingTransaction的接口:

Public Interface IRepeatingTransaction
    ' Definitions
End Interface

When I try to pass that interface as a parameter: 当我尝试将该接口作为参数传递时:

Public Sub New(R As IRepeatingTransaction)
   ' blah
End Sub

I get the compiler error: 我收到编译器错误:

'R' cannot expose type 'ModGlobals.IRepeatingTransaction' outside the project through class 'Transactions'

Use End Sub instead of brackets. 使用End Sub代替括号。

Sub MyFunc(e As IEnumerable)
    ' do something
End Sub

It's as follows. 如下。

Private Sub myFunc(e As IEnumarable)
    'do something
End Sub

公开模块或仅在模块外部创建接口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM