[英]Port code to vb.net
I found some code online. 我在网上找到了一些代码。 It is in C# and I am trying to port it to vb.net.
它在C#中,我正在尝试将其移植到vb.net。 I need some help with calling the evaluator function from within the Log subroutine.
我需要一些帮助,可以从Log子例程中调用evaluator函数。 In C#, evaluator does not appear to expect any parameters when it gets called in Log.
在C#中,当在Log中调用evaluator时,似乎没有任何参数。 However, VB keeps asking for the Match parameter.
但是,VB不断询问Match参数。 What is the magic and how should I get it to work in VB.NET?
什么是魔术,我该如何在VB.NET中使用它? Thanks.
谢谢。
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));
...
}
The C# version is using the (string, MatchEvaluator)
overload of Regex.Replace()
, and using the implicit conversion of the method name to the MatchEvaluator
delegate type. C#版本使用
Regex.Replace()
的(string, MatchEvaluator)
重载,并使用方法名称到MatchEvaluator
委托类型的隐式转换。 See the MSDN documentation on that overload. 有关该重载,请参见MSDN文档 。
On the MSDN page, this is how they call it: 在MSDN页面上,这是他们的称呼方式:
Dim result As String = rx.Replace(text, AddressOf RegExSample.CapText)
So make sure to use the AddressOf
keyword. 因此,请确保使用
AddressOf
关键字。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.