开发者

ByRef underlined with "Expression Expected" error in VB.Net when trying to pass in a object of type List(Of clsFooDetail)

开发者 https://www.devze.com 2022-12-22 07:27 出处:网络
I work with C# 99% of the time. However, I\'m having to update some legacy VB.Net code and encountering an issue with VB.Net code syntax. The error that I get is \"ByRef\" is underlined and \"Expected

I work with C# 99% of the time. However, I'm having to update some legacy VB.Net code and encountering an issue with VB.Net code syntax. The error that I get is "ByRef" is underlined and "Expected Expression" tag shows up when you hover over "ByRef".

The "FooDetail.Load" function is written in C# and expects a List object passed as reference. Don't have any trouble using the same function in other C# classes. Can someone indicate what is wrong with below VB.Net code.

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.L开发者_Go百科ist(Of(clsFooDetail))


You can't declare a variable in a method call. Nor do you use the equivalent of "out". And don't use "As New" when the method returns a new list. Write it like this:

Dim lstFooDetail As List(Of clsFooDetail)
FooDetail.Load(ConnectionString, "Stored Procedure", lstFooDetail)
0

精彩评论

暂无评论...
验证码 换一张
取 消