Extension methods can be defined only in modules
This error occurs when an extension method has been defined outside a module. In Visual Basic, all extension methods must be defined within standard modules.
Error ID: BC36551
- Place the extension method in a module.
The following example extends the String
class, adding a Print
method.
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
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: