我在 Ubuntu 10.10 中使用 MonoDevelop 2.4,我似乎无法进行简单的 C# 调用。
myList.DGraph.ForEach(delegate(string s){Console.WriteLine(s)});
我收到这个错误:
DirectedGraph.cs(219,78): error CS1525: Unexpected symbol `}'
DirectedGraph.cs(250,1): error CS1525: Unexpected symbol `}', expecting `)', or `,'
DirectedGraph.cs(251,1): error CS8025: Parsing error
最佳答案
你需要一个分号(;
)
myList.DGraph.ForEach(delegate(string s){Console.WriteLine(s);});
^
否则不是合法的方法体。
关于c# - List.Foreach(Delegate) 是在 Mono 中实现的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4380064/