将c#代码转换为VB.net

本文关键字:VB net 转换 代码 | 更新日期: 2023-09-27 18:06:25

我想把这个c#代码翻译成VB.net

var messages = animalmgr.ReadFile(thefilename); 
//Getting method from manager
if (messages != null)
{
    messages.ToList().ForEach(msg => Resultlst.Items.Add(msg));
}

我试过了:

Dim message = animalmgr.ReadFile(thefilename)
If (Not (message) Is Nothing) Then
    'I don't know how the code below are supposed to be
    message.ToList.ForEach(() => {  }, Resultlst.Items.Add(msg))
End If
如果有人能帮我,我会很感激的。谢谢。

将c#代码转换为VB.net

VB lambda函数有点不同。下面是它在VB中的样子。净:

message.ToList().ForEach(Sub(msg) Resultlst.Items.Add(msg))