我 99% 的时间都在使用 C#。但是,我不得不更新一些遗留的 VB.Net 代码并遇到 VB.Net 代码语法问题。我得到的错误是“ByRef”带有下划线,当您将鼠标悬停在“ByRef”上时,“Expected Expression”标 checkout 现。
“FooDetail.Load”函数是用 C# 编写的,需要一个 List 对象作为引用传递。在其他 C# 类中使用相同的函数不会有任何问题。有人可以指出以下 VB.Net 代码有什么问题吗。
Dim FooDetail As New clsFooDetail()
FooDetail.FooID = FooID
Dim lstFooDetail As New List(Of clsFooDetail)
FooDetail.Load(ConnectionString, "Stored Procedure", ByRef lstFooDetail as System.Collection.List(Of(clsFooDetail))
最佳答案
您不能在方法调用中声明变量。你也不使用相当于“out”的词。并且当方法返回新列表时不要使用“As New”。像这样写:
Dim lstFooDetail As List(Of clsFooDetail)
FooDetail.Load(ConnectionString, "Stored Procedure", lstFooDetail)
关于.net - 尝试传入 List(Of clsFooDetail) 类型的对象时,VB.Net 中的 ByRef 下划线带有 "Expression Expected"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2375846/