So I have constructed a function which, when called, is supposed to return a list of 'charges' and display it.
I am receiving one error from this function, which reads:
Value of type 'System.Collections.Generic.List(Of DotNetNuke.Modules.AccessorialCharges.ChargesInfo)' cannot be converted to '1-dimensional array of System.Collections.Generic.List(Of DotNetNuke.Modules.AccessorialCharges.ChargesInfo)'
I understand the error, but am unsure why I am getting it.
I have checked over the code piece by piece a number of times, and can't find my mistake.
Any suggestions are appreciated.
Code to follow:
Public Shared Function GetCharges(ByVal ModuleId As Integer) As List(Of ChargesInfo)()
Dim ChargesInfolist As List(Of ChargesInfo) = New List(Of ChargesInfo)
Using dr As IDataReader = DataProvider.Instance().GetCharges(ModuleId)
While dr.Read
Dim ChargesInfo As ChargesInfo = New ChargesInfo
ChargesInfo.ChargeId = Convert.ToInt32(dr("ChargeId"))
ChargesInfo.Expense = Convert.ToString(dr("Expense"))
ChargesInfo.OptionType = Convert.ToString(dr("OptionType"))
ChargesInfo.ViewOrder = Convert.ToInt32(ConvertNullInteger(dr("ViewOrder")))
ChargesInfo.CreatedByUser = Convert.ToInt32(dr("CreatedByUser"))
ChargesInfo.CreatedDate = Convert.ToDateTime(dr("CreatedDate"))
ChargesInfolist.Add(ChargesInfo)
End While
End Using
Return ChargesInfolist
End Function
Public Shared Function GetCharges(ByVal ModuleId
As Integer)
As List(Of ChargesInfo)()
to this:
Public Shared Function GetCharges(ByVal ModuleId
As Integer)
As List(Of ChargesInfo)
Which is missing the last () from the definition.
Brian
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
Marked as answer by Chronofied on Jan 16, 2009 04:45 PM
Chronofied
Member
22 Points
27 Posts
Trouble With Arrays
Jan 16, 2009 04:24 PM|LINK
So I have constructed a function which, when called, is supposed to return a list of 'charges' and display it.
I am receiving one error from this function, which reads:
Value of type 'System.Collections.Generic.List(Of DotNetNuke.Modules.AccessorialCharges.ChargesInfo)' cannot be converted to '1-dimensional array of System.Collections.Generic.List(Of DotNetNuke.Modules.AccessorialCharges.ChargesInfo)'
I understand the error, but am unsure why I am getting it.
I have checked over the code piece by piece a number of times, and can't find my mistake.
Any suggestions are appreciated.
Code to follow:
Public Shared Function GetCharges(ByVal ModuleId As Integer) As List(Of ChargesInfo)() Dim ChargesInfolist As List(Of ChargesInfo) = New List(Of ChargesInfo) Using dr As IDataReader = DataProvider.Instance().GetCharges(ModuleId) While dr.Read Dim ChargesInfo As ChargesInfo = New ChargesInfo ChargesInfo.ChargeId = Convert.ToInt32(dr("ChargeId")) ChargesInfo.Expense = Convert.ToString(dr("Expense")) ChargesInfo.OptionType = Convert.ToString(dr("OptionType")) ChargesInfo.ViewOrder = Convert.ToInt32(ConvertNullInteger(dr("ViewOrder"))) ChargesInfo.CreatedByUser = Convert.ToInt32(dr("CreatedByUser")) ChargesInfo.CreatedDate = Convert.ToDateTime(dr("CreatedDate")) ChargesInfolist.Add(ChargesInfo) End While End Using Return ChargesInfolist End Functionbmains
All-Star
29116 Points
5886 Posts
MVP
Re: Trouble With Arrays
Jan 16, 2009 04:37 PM|LINK
Hey,
Try changing this:
Public Shared Function GetCharges(ByVal ModuleId As Integer) As List(Of ChargesInfo)()
to this:
Public Shared Function GetCharges(ByVal ModuleId As Integer) As List(Of ChargesInfo)
Which is missing the last () from the definition.
"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4).
Chronofied
Member
22 Points
27 Posts
Re: Trouble With Arrays
Jan 16, 2009 04:45 PM|LINK
Bingo.
Thanks, man.