VB.net至" C#等效; AddressOf" [英] VB.net to C# Equivalent of "AddressOf"
问题描述
我想实现这个例子
的 http://blog.evonet.com.au/post/Gridview-with-highlighted-search-results.aspx
但我面对的唯一的问题是VB.net的AddressOf关键字对此我无法用C#.net转换
but the only problem I am facing is the AddressOf keyword of VB.net which I am unable to convert in C#.net
任何人可以帮助我。出这一点,有什么其他我应该使用,使其工作
can anybody help me out with this, what alternative I should use to make it work.
感谢
编辑:我发现计算器上的一些搜索有关类似的问题,但我无法理解他们。
I found some searches on stackoverflow regarding similar problems but I am unable to understand them.
推荐答案
您可以只留下它。方法组是隐式转换为C#中的代表。
You can just leave it out. Method groups are implicitly convertible to delegates in C#.
return ResultStr.Replace(InputTxt, new MatchEvaluator(ReplaceWords))
或者更简单(我认为这需要C#2):
Or even simpler(I think this requires C# 2):
return ResultStr.Replace(InputTxt, ReplaceWords);
不过,由于 ReplaceWords
就是这么简单,我倒是考虑lambda表达式(需要C#3):
But since ReplaceWords
is so simple, I'd consider a lambda expression(Requires C# 3):
return ResultStr.Replace(InputTxt, m => "<span class=highlight>" + m + "</span>");
这篇关于VB.net至" C#等效; AddressOf"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!