Reputation: 33867
stupid question here. I'm trying to create a helper method, something similar to the radio button list in the MVC futures project (as a learning tool).
I'm trying to convert the C# code:
public static string[] RadioButtonList(this HtmlHelper htmlHelper, string name, IDictionary<string, object> htmlAttributes) {
to a method signature in VB.net, but I'm not sure how to write the first parameter in VB.net, or what you would call this, so I could look it up?
Upvotes: 1
Views: 1794
Reputation: 18802
Extension methods in VB can only be declared from within a module, not a class, so a complete skeleton definition would look something like this...
Imports System.Web.Mvc
Public Module MyModule
<System.Runtime.CompilerServices.Extension> _
Public Function MyHelper (ByVal helper As HtmlHelper, MyParameter as String) As String
End Function
End Module
Upvotes: 1
Reputation: 60584
They are called Extension methods, and are declared in VB.Net like this:
<System.Runtime.CompilerServices.Extension()> _
Public Sub RadioButtonList(ByVal name As String, ...)
// There's no "this" parameter at all...
Upvotes: 1
Reputation: 69983
I believe this will work as long as you remember to mark it as an extension method, you could look up Extension Methods on MSDN.com. They have examples of how to write extension methods in VB.net.
<System.Runtime.CompilerServices.Extension> _
Public Shared Function RadioButtonList(ByVal htmlHelper As HtmlHelper, ByVal name As String, ByVal htmlAttributes As IDictionary(Of String, Object)) As String()
End Function
Upvotes: 2
Reputation:
I'm not either. But this is the signature of an extension method. Here's the MSDN docs on doing this in VB.
Upvotes: 2