这句C#转成vb.net该怎么写

he_kb 2019-07-29 04:22:42
AddMessageEventListener("callMe", ((string p) => { callMe(p); }));
主要是后面这个((string p) => { callMe(p); }),可以写成:
Dim myaction New Action (Of String) =sub callMe(p as String)
msgbox (s)
End
AddMessageEventListener("callMe", myaction)
...全文
86 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
hztltgg 2019-07-30
  • 打赏
  • 举报
回复
vb.net 可以简写成 mybrowser.AddMessageEventListener("myFunction", AddressOf DPrintString) 或者和c#一样用匿名,不定义DPrintString mybrowser.AddMessageEventListener("myFunction", Sub(s) Me.showMessage(s) End Sub)
he_kb 2019-07-29
  • 打赏
  • 举报
回复
因为看的是geckofx与C#交互的例子,其中这一句
geckoWebBrowser.AddMessageEventListener("myFunction", ((string s) => this.showMessage(s)))
中的第二个参数我不知道转为vb.net该如何写。 刚才进行了一个尝试,可以写成
mybrowser.AddMessageEventListener("myFunction", New Action(Of String)(AddressOf DPrintString))
。 谢谢大家!
hztltgg 2019-07-29
  • 打赏
  • 举报
回复
我好像有点看懂你的意思了,那你要定义匿名方法就不要取名 Dim myaction As Action(Of String) = Sub(p As String) MsgBox(p) End Sub
hztltgg 2019-07-29
  • 打赏
  • 举报
回复
就是个匿名方法呀,vb.net没有=>符号,还是用 sub 和 end sub框起来,你的vb.net不会版本很早的吧?老版本不支持的哦 sub(p as string) callMe(p) end sub
he_kb 2019-07-29
  • 打赏
  • 举报
回复
引用 1 楼 hztltgg的回复:
该怎么写就怎么写吧,vb.net也是支持Lambda表达式的,地址需要加个AddHandler获取这点区别。 主要是你这随便拷贝到一段,看不懂你要表达什么意思,AddMessageEventListener的函数原型拷贝出来看看,你的需求说说看。
我主要是想问((string p) => { callMe(p); })这个用vb. net该怎么写。
he_kb 2019-07-29
  • 打赏
  • 举报
回复
我主要是想问((string p) => { callMe(p); })这个用vb. net该怎么写。
hztltgg 2019-07-29
  • 打赏
  • 举报
回复
该怎么写就怎么写吧,vb.net也是支持Lambda表达式的,地址需要加个AddHandler获取这点区别。 主要是你这随便拷贝到一段,看不懂你要表达什么意思,AddMessageEventListener的函数原型拷贝出来看看,你的需求说说看。
这是第六版的介绍《ASP.NET 4入门经典:涵盖C#VB.NET(第6版)》内容简介:ASP.NET是.NET Framework的一部分,用于构建内容丰富的动态Web站点。其最新的版本ASP.NET 4对上一版进行了许多改进,包括增强了Web窗体,并添加了jQuery的支持。《ASP.NET 4入门经典:涵盖C#VB.NET(第6版)》循序渐进,逐步讲解了如何使用ASP.NET 4构建内容丰富的Web站点,并提供了大量使用C#和VB的示例。通过实际动手练习,您将学到关于构建Web站点的第一手信息,同时能够深刻理解在浏览器中查看ASP.NET 4页面时,后台到底发生了什么。 这是第七版,也就是本源码书的介绍 The ultimate programming guide to ASP.NET 4.5, by popular author and Microsoft MVP Imar Spaanjaars Updated for ASP.NET 4.5, this introductory book is filled with helpful examples and contains a user-friendly, step-by-step format. Written by popular author and Microsoft ASP.NET MVP Imar Spaanjaars, this book walks you through ASP.NET, Microsoft's technology for building dynamically generated web pages. This edition retains the highly accessible approach to building the Planet Wrox website example, an online community site featuring product reviews, picture sharing, bonus content for registered users, and more. Contains the comprehensive guide to the latest technology additions to ASP.NET 4.5 Shows how to build basic ASP.NET web pages and configure their server Includes information on how to add features with pre-built server controls Reveals how to design pages and make them consistent Contains the information needed for getting user input and displaying data Beginning ASP.NET 4.5 in C# and VB uses Spaanjaars's distinct writing style to put you at ease with learning ASP.NET 4.5.

16,555

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧