c#6.0 new Features

Source: Internet
Author: User
Tags finally block

The C # 6.0 release contains many features that can improve developer productivity. features in this release include the following:

  • Read-only automatic properties:
    • You can create a read-only automatic property that can be set only in the constructor.
  • Automatic Property initializers:
    • You can write an initialization expression to set the initial value of an automatic property.
  • expression-bodied function Members:
    • You can use a lambda expression to create a single-line method.
  • Using static:
    • You can import all methods of a single class into the current namespace.
  • Null-Conditional operator:
    • You can access the members of an object concisely and securely, while still checking for NULL using the null condition operator.
  • String interpolation:
    • You can use inline expressions instead of positional arguments to write string formatting expressions.
  • Exception Filters:
    • You can capture an expression based on a property of an exception or other program state.
  • Nameof expression:
    • You can have the compiler generate a string representation of the symbol.
  • Await in Catch and Finally block:
    • You can use them where you have not previously allowed await expressions to be used.
  • Index initializers:
    • You can create an initialization expression for an associative container and a sequence container.
  • Extension methods for collection initializers:
    • In addition to the member method, a collection initializer can also rely on an accessible extension method.
  • Improved overload resolution:
    • Some constructs that have previously generated ambiguous method calls can now be parsed correctly.

The overall effect of these features is to make the code you write more concise and more readable. This syntax is not as cumbersome as many common practices. design Intent can be seen more easily. having a good understanding of these features can help you work more efficiently, write more readable code, and focus more on core functionality than language constructs.

Original: Https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-new/csharp-6

c#6.0 new Features

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.