Tổng hợp các tính năng trên phiên bản C# 7

Ở bài này, mình sẽ giới thiệu những cải tiến được Microsoft tích hợp vào C# 7. Bạn nào muốn biết thêm về sự phát triển của C# từ bản 1.0 lên 8.0 hãy đọc bài cũ của mình ở đây nhé.



Ở phiên bản này Microsoft có chia nhỏ ra làm nhiều phiên bản con 7.0, 7.1, 7.2 và 7.3

C# 7.0




  • out variables
  • Tuples
  • Discards
  • Pattern Matching
  • ref locals and returns
  • Local Functions
  • More expression-bodied members
  • throw Expressions
  • Generalized async return types
  • Numeric literal syntax improvements


Các bạn vui lòng tham khảo file bên dưới để hiểu thêm chi tiết



C# 7.1


  • async Main method
  • default literal expressions
  • Inferred tuple element names
  • Pattern matching on generic type parameters


Các bạn vui lòng tham khảo file bên dưới để hiểu thêm chi tiết



C# 7.2


  • Techniques for writing safe efficient code
  • Non-trailing named arguments
  • Leading underscores in numeric literals
  • Private protected access modifier
  • Conditional ref expressions


Các bạn vui lòng tham khảo file bên dưới để hiểu thêm chi tiết



C# 7.3


  • You can access fixed fields without pinning.
  • You can reassign ref local variables.
  • You can use initializers on stackalloc arrays.
  • You can use fixed statements with any type that supports a pattern.
  • You can use additional generic constraints.
  • You can test == and != with tuple types.
  • You can use expression variables in more locations.
  • You may attach attributes to the backing field of auto-implemented properties.
  • Method resolution when arguments differ by in has been improved.
  • Overload resolution now has fewer ambiguous cases.



Tiếp tục cập nhật ...