我正在尝试将元组从c#转换为vb.net.这是元组的声明 -
private List<Tuple<string, string, Action<T, string>>> items = new List<Tuple<string, string, Action<T, string>>>();
Run Code Online (Sandbox Code Playgroud)
我将项目添加到Item3(动作),就像这样 -
foreach(var iforeach(var i in items)
{
i.Item3(t, string.Empty);
}
Run Code Online (Sandbox Code Playgroud)
在vb.net中,我将我的元组定义如下 -
Private list As New List(Of Tuple(Of String, String, Action(Of T, String)))
Run Code Online (Sandbox Code Playgroud)
并试图像这样添加一个动作到Item3 -
Dim mytype = Activator.CreateInstance(Of T)
For Each item As Tuple(Of String, String, Action(Of T, String)) In list
item.Item3(mytype, String.Empty)
Next
Run Code Online (Sandbox Code Playgroud)
我已经尝试了不同方式的各种迭代来向Item3添加Action,但似乎没有用.对于上面的示例,我在VS中获得以下消息 - 参考的参数数量不正确....
任何人都可以了解如何将其转换为vb.net?谢谢.
您不需要使用单独的变量 - 只需使用显式空括号对来防止编译器混淆(将'Item3'误解为参数化属性,如Darryl所说):
For Each i In items
i.Item3()(mytype, String.Empty)
Next i
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
284 次 |
最近记录: |