Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List as Class Property 1

Status
Not open for further replies.

rvBasic

Programmer
Oct 22, 2000
414
BE
Following code reflects an attempt to create a class that has a list as its property
Code:
Public Class AppParms

    Private m_parmbag() As List(Of AppParm)

    Property Parmbag() As List(Of AppParm)
        Get
            [COLOR=red]Return m_parmbag[/color]
        End Get
        Set(ByVal value As List(Of AppParm))
            [COLOR=red]m_parmbag = value[/color]
        End Set
    End Property

    Public Sub New()
        Parmbag() = New List(Of AppParm)
    End Sub

    Public Class AppParm
        Public Property ParmName As String
        Public Property ParmValue As String
        Public Property ParmDefault As String
        Public Property Dirty As Boolean
    End Class

End Class

Both red statements are flagged with a similar error:
Value of type '1-dimensional array of System.Collections.Generic.List(Of con_AppParmCollection.AppParms.AppParm)' cannot be converted to 'System.Collections.Generic.List(Of con_AppParmCollection.AppParms.AppParm)'.

When I replaced the first red statement with
Code:
 For Each ap As AppParm In m_parmbag
                Parmbag.Add(ap)
            Next
m_parmbag was flagged with the same error.

Help is appreciated.

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
by placing () after the variable name you created a 1-d array of lists(of appParm), instead of a list of appParm

Private m_parmbag as list(0f Appparm)
not
Private m_parmbag() As List(Of AppParm)
 
How evident (if only you know it). Thanks!

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top