`` Operator usage? " /> <code class=" language-csharp>public int MaxHealth => Memory[Address].IsValid ? Memory[Address].Read<int>(Offs.Life.MaxHp) : 0; </p> <p> <strong> </strong> Field initialization </p> <div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false"><code class="language-csharp">public int MaxHealth { get { return Memory[Address].IsValid ? Memory[Address].Read<int>(Offs.Life.MaxHp) : 0; } }</code>
=>
Wait for:
<code class="language-csharp">public int MaxHealth = x ? y : z;</code>
Key differences:
The key difference between<code class="language-csharp">public int MaxHealth; // 字段声明 public int MaxHealth = x ? y : z; // 字段赋值</code>
Lambda expression
In the Lambda expression, theoperator is used to separate the input parameters of the anonymous function from its subject. Lambda expression is used to define anonymous method or expression that can be passed to other functions as parameters. They have nothing to do with expression members.
The above is the detailed content of Expression-Bodied Members vs. Lambda Expressions: What's the Difference in C#'s `=>` Operator Usage?. For more information, please follow other related articles on the PHP Chinese website!