What is the => token called?

后端 未结 5 1818
广开言路
广开言路 2020-12-06 17:47

The => token is part of the C# 3.0 lambda syntax. My efforts to find the name of this token have failed so far.

相关标签:
5条回答
  • 2020-12-06 17:57

    http://msdn.microsoft.com/en-us/library/bb397687.aspx

    Taken from the above: All lambda expressions use the lambda operator =>, which is read as "goes to".

    0 讨论(0)
  • 2020-12-06 17:58

    Lambda operator

    0 讨论(0)
  • 2020-12-06 18:00

    What it is called, in terms of how to pronounce it when reading code, is covered by Eric Lippert in Reading Code Over the Telephone.

    0 讨论(0)
  • 2020-12-06 18:05

    It's referred to as the 'goes to' operator.

    0 讨论(0)
  • 2020-12-06 18:22

    Turns out the answer depends on the context:

    c=>c+1
    

    c goes to c plus one

    (Customer c)=>c.Name
    

    customer c becomes c dot name

    (Customer c)=>c.Age > 21
    

    customer c such that c dot age is greater than 21

    0 讨论(0)
提交回复
热议问题