为了简洁和清晰起见,我想将几行VB代码转换为函数调用。目前,代码填充了通用列表的动态数组:
Dim itemCount as Integer = 5
Dim myarr(itemCount - 1) As List(Of DataRow)
' some code that populates myarr
对于将返回myarr
的函数,返回类型的语法是什么?
答案 0 :(得分:1)
以下是示例代码。类型为List(Of DataRow)()
,也可以通过TypeName
验证。
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim m() As List(Of DataRow)
m = getTest()
End Sub
Private Function getTest() As List(Of DataRow)()
Dim m(10) As List(Of DataRow)
MessageBox.Show(TypeName(m))
For i = 0 To 10
m(i) = New List(Of DataRow)
Next
Return m
End Function