gpt4 book ai didi

c# - List.Foreach(Delegate) 是在 Mono 中实现的吗?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:30:00 31 4
gpt4 key购买 nike

我在 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

它似乎不喜欢这样,尽管据我所知,this is valid .

最佳答案

你需要一个分号(;)

myList.DGraph.ForEach(delegate(string s){Console.WriteLine(s);});
^

否则不是合法的方法体。

关于c# - List.Foreach(Delegate) 是在 Mono 中实现的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4380064/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com