C# vb.net的端口代码

C# vb.net的端口代码,c#,vb.net,C#,Vb.net,我在网上找到了一些代码。它是用C#编写的,我正在尝试将它移植到vb.net。我需要从日志子例程中调用evaluator函数的帮助。在C#中,当在日志中调用evaluator时,它似乎不需要任何参数。但是,VB一直要求匹配参数。什么是魔力?我应该如何让它在VB.NET中工作?谢谢 private string evaluator(Match match) { Pri pri = new Pri(match.Groups[1].Value); return pri.ToString(

我在网上找到了一些代码。它是用C#编写的,我正在尝试将它移植到vb.net。我需要从日志子例程中调用evaluator函数的帮助。在C#中,当在日志中调用evaluator时,它似乎不需要任何参数。但是,VB一直要求匹配参数。什么是魔力?我应该如何让它在VB.NET中工作?谢谢

private string evaluator(Match match)
{
    Pri pri = new Pri(match.Groups[1].Value);
    return pri.ToString()+" ";
}

private void Log(EndPoint endPoint, string strReceived)
{
...
string strMessage = string.Format("{0} : {1}", 
    endPoint, m_regex.Replace(strReceived, evaluator));
...
}
C版本使用
Regex.Replace()
(字符串,MatchEvaluator)
重载,并使用方法名称到
MatchEvaluator
委托类型的隐式转换。请参阅有关过载的详细信息

在MSDN页面上,他们这样称呼它:

Dim result As String = rx.Replace(text, AddressOf RegExSample.CapText)
因此,请确保使用
AddressOf
关键字