Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#到vb.net转换的参数太少_.net_Vb.net - Fatal编程技术网

c#到vb.net转换的参数太少

c#到vb.net转换的参数太少,.net,vb.net,.net,Vb.net,在第一行,我得到了一个错误:system.collections.generic.list(of T)它必须是system.collections.generic.list(of Object),其中Object是列表中包含的实际类型。我将这样写: Friend Shared Sub dumpRows(rowList As System.Collections.Generic.List, msg As [String]) msg = If((msg Is Nothing)

在第一行,我得到了一个错误:system.collections.generic.list(of T)

它必须是
system.collections.generic.list(of Object)
,其中
Object
是列表中包含的实际类型。

我将这样写:

Friend Shared Sub dumpRows(rowList As System.Collections.Generic.List, msg As [String])
            msg = If((msg Is Nothing), "***** ", "***** " & msg)
            Dim row As [Object] = Nothing
            info(vbLf & msg)
            info("** Begin Row Dump:")
            Dim iter As Iterator = rowList.iterator()
            While iter.hasNext()
                row = iter.[next]()
                info(row.ToString())
            End While
            info("** End Row Dump." & vbLf)
        End Sub
正如其他人所说,您需要声明
列表包含的类型

其他一些注意事项:

  • 我从前面删除了
    System.Collections.Generic
    名称空间 因为我相信这个名称空间是由 违约你可能得把它加回去,但我怀疑

  • 我不知道为什么您使用的转换工具在类名
    字符串
    周围放了方括号。它们不是必需的

  • 由于您基本上只是将
    msg
    设置为在之前的内容前面有5个星号,因此可以使用合并 三元条件的。这使代码更简洁

  • 如果只在
    While
    循环中使用
    行,则没有理由在如此大的范围内声明


  • 我不使用VB.NET,但是您不应该指定列表的类型吗?这里有问题吗?
    Friend Shared Sub dumpRows(rowList As List(Of Object), msg As String)
        msg = "***** " & If(msg, String.Empty)
        info(vbLf & msg)
        info("** Begin Row Dump:")
        Dim iter As Iterator = rowList.iterator()
        While iter.hasNext()
            Dim row As Object = iter.[next]()
            info(row.ToString())
        End While
        info("** End Row Dump." & vbLf)
    End Sub