我试图将此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
如果有人能帮助我,我将不胜感激。感谢。
答案 0 :(得分:4)
VB lambda函数有点不同。以下是它在VB.Net中的外观:
message.ToList().ForEach(Sub(msg) Resultlst.Items.Add(msg))