Ruffone
asked on
Member 'names' cannot be initialized in an object initializer expression because it is shared
How can I ininitialize the "names" property on the "TestPerson" class. The code below throws an error. "Member 'names' cannot be initialized in an object initializer expression because it is shared"
Return From p In Me.peopleRep.GetAll()
Let names = Me.nameSvc.GetAll(p.personGuid)
Select New Credit.Person _
With {.personId = p.personId,
.birthDay = p.birthDay,
.gender = p.gender,
.names = New ObservableCollection(Of Credit.Name)(names)
}
Public Class TestPerson
Public Property birthDay As String
Public Property gender As String
Public Shared Property names As ICollection(Of Name)
Get
Return _names
End Get
Set(value As ICollection(Of Name))
_names = value
End Set
End Property
Private Shared _names As ObservableCollection(Of Name) = Nothing
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
See the Note section on this page.
http://msdn.microsoft.com/en-us/library/4hbsxy95(v=vs.90).aspx
You could also potentially initialize names like this forgive me this is rough
Open in new window