Reputation: 225
I found some code online. It is in C# and I am trying to port it to vb.net. I need some help with calling the evaluator function from within the Log subroutine. In C#, evaluator does not appear to expect any parameters when it gets called in Log. However, VB keeps asking for the Match parameter. What is the magic and how should I get it to work in 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));
...
}
Upvotes: 0
Views: 87
Reputation: 24232
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. See the MSDN documentation on that overload.
On the MSDN page, this is how they call it:
Dim result As String = rx.Replace(text, AddressOf RegExSample.CapText)
So make sure to use the AddressOf
keyword.
Upvotes: 1