【发布时间】:2025-12-14 00:20:05
【问题描述】:
有一个 Action 委托并尝试在其中使用三元运算符和 lambda:
Action<string> action = new Action<string>( str => (str == null) ?
Console.WriteLine("isnull") : Console.WriteLine("isnotnull")
给出旧的“只允许赋值、递减等”错误。
这有可能吗?
【问题讨论】:
标签: c# delegates lambda ternary-operator