相关疑难解决方法(0)

?:?? 运算符而不是IF | ELSE

public string Source
{
    get
    {
        /*
        if ( Source == null ){
            return string . Empty;
        } else {
            return Source;
        }
        */
        return Source ?? string.Empty;
    }
    set
    {
        /*
        if ( Source == null ) {
            Source = string . Empty;
        } else {
            if ( Source == value ) {
                Source = Source;
            } else {
                Source = value;
            }
        }
        */
        Source == value ? Source : value ?? string.Empty;
        RaisePropertyChanged ( "Source" );
    } …
Run Code Online (Sandbox Code Playgroud)

c# ternary-operator

84
推荐指数
3
解决办法
23万
查看次数

标签 统计

c# ×1

ternary-operator ×1