Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The members initialized in an object initializer list must be fields or properties, and property members cannot have parameters. For example, default properties require arguments, so they cannot be initialized in an object initializer list. For more information, see Default Properties.
Error ID: BC30992
To correct this error
- Remove from the initialization list all properties that have arguments.
Example
The following class contains a default property, defaultProp, that requires an integer argument.
Public Class SomeStrings
Private myStrings() As String
Sub New(ByVal size As Integer)
ReDim myStrings(size)
End Sub
Default Property defaultProp(ByVal index As Integer) As String
Get
Return myStrings(index)
End Get
Set(ByVal Value As String)
myStrings(index) = Value
End Set
End Property
End Class
Because the default property requires an argument, the following declaration causes an error.
' Dim strs As New SomeStrings(2) With { .defaultProp = "One" }