What's the difference between these two ways to add something?
private string abc => "def";
And
private string abc = "def";
The difference is that one modifies the data-structure itself (in-place operation) b += 1 while the other just reassigns the variable a = a + 1 .
+ is an arithmetic operator while += is an assignment operator.. When += is used, the value on the RHS will be added to the variable on the LHS and the resultant value will be assigned as the new value of the LHS..
The solution means to say that there is no difference, ++i has the same meaning as (i += 1) no matter what i happens to be and no matter the context of the expression.
The Python += operator performs an addition operator and then assigns the result of the operation to a variable. The += operator is an example of a Python assignment operator.
This is the declaration of a classic field as it has always existed in C#:
private string abc = "def";
The field is immediately assigned an initial value.
This is a shorthand syntax for declaring a getter-only property (or expression-bodied property), introduced in C# 6:
private string abc => "def";
It's a short way to write the following:
private string abc
{
get { return "def"; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With