将C#代码转换为VB.net

时间:2015-08-05 13:26:46

标签: c# vb.net

我试图将此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

如果有人能帮助我,我将不胜感激。感谢。

1 个答案:

答案 0 :(得分:4)

VB lambda函数有点不同。以下是它在VB.Net中的外观:

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