확장 메서드는 모듈에만 정의할 수 있습니다.
업데이트: 2007년 11월
Extension methods can be defined only in modules
이 오류는 확장 메서드를 모듈 외부에 정의한 경우 발생합니다. Visual Basic에서 모든 확장 메서드는 표준 모듈 내에 정의되어야 합니다.
오류 ID: BC36551
이 오류를 해결하려면
- 확장 메서드를 모듈 내에 배치합니다.
예제
다음 예제에서는 Print 메서드를 추가하여 String 클래스를 확장합니다.
Imports StringUtility
Imports System.Runtime.CompilerServices
Namespace StringUtility
<Extension()> _
Module StringExtensions
<Extension()> _
Public Sub Print (ByVal str As String)
Console.WriteLine(str)
End Sub
End Module
End Namespace