Convert to VB.NET?


Smokey Grindel

I understand generics in VB.NET but how do you convert this C# code to

/// <summary>

/// Routing handler.

/// </summary>

/// <typeparam name="T">Type of <see cref="IHttpHandler"/> to instantiate
and return.</typeparam>

public class WebFormRouteHandler<T> : IRouteHandler where T : IHttpHandler,


public string VirtualPath { get; set; }

public WebFormRouteHandler( string virtualPath )


this.VirtualPath = virtualPath;


#region IRouteHandler Members

public IHttpHandler GetHttpHandler( RequestContext requestContext )


foreach ( var value in requestContext.RouteData.Values )


requestContext.HttpContext.Items[ value.Key ] = value.Value;


return ( VirtualPath != null )

? (IHttpHandler)BuildManager.CreateInstanceFromVirtualPath( VirtualPath,
typeof( T ) )

: new T();




David Anton

(via Instant VB):
''' <summary>
''' Routing handler.
''' </summary>
''' <typeparam name="T">Type of <see cref="IHttpHandler"/> to instantiate
and return.</typeparam>
Public Class WebFormRouteHandler(Of T As {IHttpHandler, New})
Implements IRouteHandler
Private privateVirtualPath As String
Public Property VirtualPath() As String
Return privateVirtualPath
End Get
Set(ByVal value As String)
privateVirtualPath = value
End Set
End Property
Public Sub New(ByVal virtualPath As String)
Me.VirtualPath = virtualPath
End Sub

#Region "IRouteHandler Members"
Public Function GetHttpHandler(ByVal requestContext As RequestContext) As
IHttpHandler Implements IRouteHandler.GetHttpHandler
For Each value In requestContext.RouteData.Values
requestContext.HttpContext.Items(value.Key) = value.Value
Next value
If (VirtualPath IsNot Nothing) Then
Return CType(BuildManager.CreateInstanceFromVirtualPath(VirtualPath,
GetType(T)), IHttpHandler)
Return New T()
End If
End Function
#End Region
End Class
C++ to C#
C++ to VB
C++ to Java
VB & C# to Java
Java to VB & C#
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++: VB, C#, or Java to C++/CLI

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question