当前位置:  开发笔记 > 编程语言 > 正文

c#到vb.net转换 - Action(Of T,string)作为元组项

如何解决《c#到vb.net转换-Action(OfT,string)作为元组项》经验,为你挑选了1个好方法。

我正在尝试将元组从c#转换为vb.net.这是元组的声明 -

private List>> items = new List>>();

我将项目添加到Item3(动作),就像这样 -

foreach(var iforeach(var i in items)
{
    i.Item3(t, string.Empty);
}

在vb.net中,我将我的元组定义如下 -

Private list As New List(Of Tuple(Of String, String, Action(Of T, String)))

并试图像这样添加一个动作到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

我已经尝试了不同方式的各种迭代来向Item3添加Action,但似乎没有用.对于上面的示例,我在VS中获得以下消息 - 参考的参数数量不正确....

任何人都可以了解如何将其转换为vb.net?谢谢.



1> Dave Doknjas..:

您不需要使用单独的变量 - 只需使用显式空括号对来防止编译器混淆(将'Item3'误解为参数化属性,如Darryl所说):

For Each i In items
    i.Item3()(mytype, String.Empty)
Next i

推荐阅读
黄晓敏3023
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有