VB.net至&QUOT C#等效; AddressOf" [英] VB.net to C# Equivalent of "AddressOf"

查看:137
本文介绍了VB.net至&QUOT C#等效; 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至&QUOT C#等效; AddressOf&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆