자동 구현 속성을 해당 선언의 일부로 초기화할 수 있지만 확장 속성은 그렇게 할 수 없습니다.
오류 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
참고 항목
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET