动作委托c#转换为vb.net

时间:2014-05-13 05:37:41

标签: vb.net asp.net-web-api delegates

我在将此转换为vb.net时遇到问题

c#

global.asax

protected void Application_BeginRequest()
{
    GlobalConfiguration.Configure(WebApiConfig.Register);
}

public static void Register(HttpConfiguration config)
{                       
    config.Routes.Clear();            
}

vb.net

Protected Sub Application_BeginRequest()
    GlobalConfiguration.Configure(WebApiConfig.Register)          
End Sub

Shared Function Register() As Action(Of HttpConfiguration)

End Function

我在注册方法的vb.net版本中遇到问题。如何像在c#中一样访问HttpConfiguration的参数。

1 个答案:

答案 0 :(得分:6)

您必须使用AddressOf运算符:

Protected Sub Application_BeginRequest()
    GlobalConfiguration.Configure(AddressOf WebApiConfig.Register)
End Sub

Public Shared Sub Register(config As HttpConfiguration)
    config.Routes.Clear()
End Sub