• C#中() =>是什么意思


    如题C#中() =>是什么意思,比如
    public ICommand AddCommand
    {
    get
    {
    if (this.addCommand == null)
    this.addCommand = new RelayCommand(() => this.AddPerson(), () => this.CanAddPerson());

    return this.addCommand;
    }
    }

    ====================================================================================

    解答:

    是 .NET3.0以后的新特性 Lambda表达式

    RelayCommand(() => this.AddPerson(), () => this.CanAddPerson());的意思可以翻译为

    RelayCommand(参数度一知, 参数二);
    参数一 :道() => this.AddPerson()
    参数二 :() => this.CanAddPerson()

    () => this.AddPerson() 的意思是 一个没有参数的方法,返回回 this.AddPerson() 而这个返回值的类型不用指定 系统会自动判断答
    同理 () => this.CanAddPerson() 就是 一个没有参数的方法返回this.CanAddPerson()

     


    参数一 :道() => this.AddPerson()
    参数二 :() => this.CanAddPerson()

    () => this.AddPerson() 的意思是 一个没有参数的方法,返回回 this.AddPerson() 而这个返回值的类型不用指定 系统会自动判断
    同理 () => this.CanAddPerson() 就是 一个没有参数的方法返回this.CanAddPerson()

     

    这是 .NET3.0以后百的新特性 Lambda表达式

    RelayCommand(() => this.AddPerson(), () => this.CanAddPerson());

    的意思可以翻译为

    RelayCommand(参数度一知, 参数二);
    参数一 :道() => this.AddPerson()
    参数二 :() => this.CanAddPerson()

    () => this.AddPerson() 的意思是 一个没有参数的方法,返回回 this.AddPerson() 而这个返回值的类型不用指定 系统会自动判断
    同理 () => this.CanAddPerson() 就是 一个没有参数的方法返回this.CanAddPerson()


    RelayCommand(() => this.AddPerson(), () => this.CanAddPerson());

    的意思可以翻译为

    RelayCommand(参数度一知, 参数二);
    参数一 :道() => this.AddPerson()
    参数二 :() => this.CanAddPerson()

    () => this.AddPerson() 的意思是 一个没有参数的方法,返回回 this.AddPerson() 而这个返回值的类型不用指定 系统会自动判断
    同理 () => this.CanAddPerson() 就是 一个没有参数的方法返回this.CanAddPerson()

  • 相关阅读:
    [leetCode]09.用两个栈实现队列
    ubuntu:无法获得锁;无法锁定管理目录
    [leetCode]07.重建二叉树
    [leetCode]剑指 Offer 06. 从尾到头打印链表
    [leetCode]剑指 Offer 05. 替换空格
    [leetCode]1330.翻转子数组得到最大的数组值
    [leetCode]312.戳气球
    UVALive
    CodeChef
    CodeChef
  • 原文地址:https://www.cnblogs.com/zbliao/p/12854814.html
Copyright © 2020-2023  润新知