zoukankan      html  css  js  c++  java
  • 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()

  • 相关阅读:
    STP配置和选路规则
    Apache(基于端口号)
    Apache(基于主机名)
    Apache(基于IP地址)
    (Apache服务)个人用户主页功能
    c语言实现通讯录,包括增加名字,删除信息,查找,修改,排序
    C语言用函数指针的数组简单实现计算器功能
    指针与数组,指针与函数之间的关系
    循环
    SQLite不支持的SQL语法总结
  • 原文地址:https://www.cnblogs.com/zbliao/p/12854814.html
Copyright © 2011-2022 走看看