Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想看看匿名方法如何工作并在标签中显示结果(Windows 窗体):
label1.Text = () => { return "Some text"; };
但这是行不通的。怎么修的?
尝试这个:
label1.Text = new Func<string>(() => { return "Some text"; })();
尝试这个
Func<string> func = () => { return "Some text"; }; label1.Text= func();
在一行中
label1.Text= new Func<string>(() => "Some text")();