You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C# 7.3本地函数中能否使用三元运算符?语法错误排查求助

C#语法问题解答

版本支持结论

C# 7.3版本支持本地函数语法,你遇到编译错误是三元运算符的使用规则不符合规范导致,与本地函数特性无关。

正确语法示例

public static void foo()
{
    // Local function
    int? parseAppliedAmountTernary( decimal? d ) { 
        return d.HasValue ? Convert.ToInt32( Math.Round(d.Value, 0) ) : null;
    }
    
    // The rest of foo...
}

内容的提问来源于stack exchange,提问作者Vince I

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 01:45:07