확장된 속성은 초기화할 수 없습니다.

자동 구현 속성을 해당 선언의 일부로 초기화할 수 있지만 확장 속성은 그렇게 할 수 없습니다.

오류 ID: BC36714

이 오류를 해결하려면

  • 자동으로 구현된 속성을 사용하거나 속성 선언에서 초기화를 제거합니다.

예시

다음 예제에서는 자동으로 구현된 속성과 확장된 속성을 모두 보여 줍니다. 할당 또는 New 절을 사용하여 자동으로 구현된 속성을 초기화할 수 있지만 확장된 속성은 초기화할 수 없습니다.

Class AutoImplementedExample  
    ' An automatically implemented property can be assigned an initial value.  
    Property IDNum As Integer = 33542  
    ' An automatically implemented property can be initialized with New.  
    Property Name As New String("Don Hall")  
End Class  
  
Class ExpandedExample  
    ' Attempting to expand an initialized automatically implemented property  
    ' causes this error.  
    'Property IDNum As Integer = 33542  
    '    Get  
    '    End Get  
    '    Set(ByVal value As Integer)  
    '    End Set  
    'End Property  
  
    ' Instead, you can assign the initial value to the backing field.  
    Private _IDNum As Integer = 33542  
    Property IDNum As Integer  
        Get  
        End Get  
        Set(ByVal value As Integer)  
        End Set  
    End Property  
End Class  

참고 항목