.net - 尝试传入 List(Of clsFooDetail) 类型的对象时,VB.Net 中的 ByRef 下划线带有 "Expression Expected"错误

标签 .net vb.net c#-to-vb.net vb.net-to-c#

我 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/

相关文章:

在参数中调用时缺少 Javascript 斜杠

MysqlException 未处理 DataReader 必须关闭此连接 vb.net

.net - Vb.NET 索引属性

c# - 将算法从 C# 转换为 VB.NET 失败

c# - 如何将此泛型方法从 C# 转换为 VB.Net

c# - 尝试在 : await Task. 之外捕获 Run(()

.net - 对具有多个依赖项的 WCF 服务进行单元测试

c# - 为什么在Nuget上找到的包不是最新版本?

vb.net - MustOverride 具有混合访问级别 Get/Set 的属性

c# - ASP.Net:在共享/静态函数中使用 System.Web.UI.Control.ResolveUrl()