C # 6.0 (C # VNext) new features: semicolon operator

Source: Internet
Author: User
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:
  1. Declaring variable result
  2. Declaring variable X
  3. Call Foo method
  4. Assigns the callback value of the Foo method to X
  5. Call the Write method and pass in the value of X
  6. Execute x * x
  7. 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
  1. Randomly get a variable (0 to 10)
  2. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.