Although this feature may not be available in the official version, it doesn't hurt to know about it.
Semicolon Operator: semicolon operator
Why is it called operator?
Generally we see, like addition, subtraction operators, but this is also called the operation method is why?
Let's take a look at the example:
var result = (var x = Foo (); Write (x); x * x);
It means:
- Declaring variable result
- Declaring variable X
- Call Foo method
- Assigns the callback value of the Foo method to X
- Call the Write method and pass in the value of X
- Execute x * x
- Assigns the value of x * x to result
So, I understand that the purpose of the semicolon operator is to be used to separate multiple expressions.
And many of these expressions, respectively, are executed from left to right.
The last expression can return the result to the outside: parentheses outside
It is important to note that the declared X variable can be used only in parentheses
Next Example:
var x = (var y = rand (ten); y * y);
As a result of the previous example
- Randomly get a variable (0 to 10)
- Then multiply and assign the result to the variable X
When it comes to this wrap, it's not quite as if it's appropriate to use this.
C # 6.0 (C # VNext) new features: semicolon operator