Skip to content

add what's new in 7.2 #3672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/csharp/whats-new/csharp-7-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: What's new in C# 7.2
description: An overview of new features in C# 7.2.
keywords: C# language design, 7.2, Visual Studio 2017,
author: billwagner
ms.author: wiwagn
ms.date: 08/16/2017
ms.topic: article
ms.prod: .net
ms.devlang: devlang-csharp
---
# What's new in C# 7.2

C# 7.2 is another point release that adds a number of useful features.
One theme for this release is working more efficiently with value types by
avoiding unnecessary copies or allocations.

The remaining features are small, nice-to-have features.

C# 7.2 uses the [language version selection](csharp-7-1.md#language-version-selection)
configuration element to select the compiler language version.

The new language features in this release are:

* [Reference semantics with value types](#reference-semantics-with-value-types)
- A combination of syntax improvements that enable working with value types using reference semantics.
* [Non-trailing named arguments](#non-trailing-named-arguments)
- Named arguments can be followed by positional arguments.
* [Leading underscores in numeric literals](#leading-underscores-in-numeric-literals)
- Numeric literals can now have leading underscores before any printed digits.
* [`private protected` access modifier](#private-protected)
- The `private protected` access modifier enables access for derived classes in the same assembly.

## Reference semantics with value types

Language features introduced in 7.2 let you work with value types
while using reference semantics. They
are designed to increase performance by minimizing copying value types without
incurring the memory allocations associated with using reference types. The
features include:

- The `in` modifier on parameters, to specify that an argument is passed by reference but not modified by the called method.
- The `ref readonly` modifier on method returns, to indicate that a method returns its value by reference but doesn't allow writes to that object.
- The `readonly struct` declaration, to indicate that a struct is immutable and should be passed as an `in` parameter to its member methods.
- The `ref struct` declaration, to indicate that a struct type accesses managed memory directly and must always be stack allocated.

You can read more about all these changes in [Using value types with reference semantics](../reference-semantics-with-value-types.md).

## Non-trailing named arguments

Method calls may now use named arguments that precede positional arguments when those
named arguments are in the correct positions. For more information see
[Named and optional arguments](../programming-guide/classes-and-structs/named-and-optional-arguments.md).

## Leading underscores in numeric literals

The implementation of support for digit separators in C# 7.0
didn't allow the `_` to be the first character of the literal value. Hex
and binary numeric literals for may now begin with an `_`.

For example:

```csharp
int binaryValue = 0b_0101_0101;
```

## `private protected`

Finally, a new compound access modifier: `private protected` indicates that a member may be
accessed by derived classes that are declared in the same assembly. While `protected internal`
allows access by derived classes or classes that are in the same assembly, `private protected`
limits access to derived types declared in the same assembly.

For more information see [access modifiers](../language-reference/keywords/access-modifiers.md) in the language reference.
14 changes: 9 additions & 5 deletions docs/csharp/whats-new/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: How is the C# language evolving
keywords: C#, Latest Features, What's New, Roslyn
author: BillWagner
ms.author: wiwagn
ms.date: 03/21/2017
ms.date: 11/13/2017
ms.topic: article
ms.prod: .net
ms.technology: devlang-csharp
Expand All @@ -15,17 +15,21 @@ ms.assetid: 77deec51-a14d-46d4-9bb3-faf449477149
# What's new in C# #

This page provides a roadmap of new features in each major release of
the C# language. The links below provide detailed information on the
the C# language. The following links provide detailed information on the
major features added in each release.

> [!IMPORTANT]
> The C# language relies on types and methods in a *standard library* for some of the features. One example is exception processing. Every `throw` statement or expression is checked to ensure the object being thrown is derived from <xref:System.Exception>. Similarly, every `catch` is checked to ensure that the type being caught is derived from <xref:System.Exception>. Each version may add new requirements. To use the latest language features in older environments, you may need to install specific libraries. These are documented in the page for each specific version. You can learn more about the [relationships between language and library](relationships-between-language-and-library.md) for background on this dependency.
> The C# language relies on types and methods in a *standard library* for some of the features. One example is exception processing. Every `throw` statement or expression is checked to ensure the object being thrown is derived from <xref:System.Exception>. Similarly, every `catch` is checked to ensure that the type being caught is derived from <xref:System.Exception>. Each version may add new requirements. To use the latest language features in older environments, you may need to install specific libraries. These dependencies are documented in the page for each specific version. You can learn more about the [relationships between language and library](relationships-between-language-and-library.md) for background on this dependency.


* [C# 7.2](csharp-7-2.md):
- This page describes the latest features in the C# language. C# 7.2 is currently available in [Visual Studio 2017 version 15.5](https://www.visualstudio.com/vs/whatsnew/), and in the [.NET Core 2.0 SDK](../../core/whats-new/index.md).

* [C# 7.1](csharp-7-1.md):
- This page describes the latest features in the C# language. This covers C# 7.1, currently available in [Visual Studio 2017 version 15.3](https://www.visualstudio.com/vs/whatsnew/), and in the [.NET Core 2.0 SDK](../../core/whats-new/index.md).
- This page describes the features in C# 7.1. These features were added in [Visual Studio 2017 version 15.3](https://www.visualstudio.com/vs/whatsnew/), and in the [.NET Core 2.0 SDK](../../core/whats-new/index.md).

* [C# 7](csharp-7.md):
- This page describes the features added in C# 7. These were added in [Visual Studio 2017](https://www.visualstudio.com/vs/whatsnew/) and [.NET Core 1.0](../../core/whats-new/index.md) and later
- This page describes the features added in C# 7. These features were added in [Visual Studio 2017](https://www.visualstudio.com/vs/whatsnew/) and [.NET Core 1.0](../../core/whats-new/index.md) and later

* [C# 6](csharp-6.md):
- This page describes the features that were added in C# 6. These features are available in Visual Studio 2015 for Windows developers, and on .NET Core 1.0 for developers exploring C# on macOS and Linux.
Expand Down
1 change: 1 addition & 0 deletions docs/toc.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
<!-- The "What's New" section is short, and one level
deep, so leave it in the main TOC -->
## [What's new in C#](csharp/whats-new/index.md)
### [What's new in C# 7.2](csharp/whats-new/csharp-7-2.md)
### [What's new in C# 7.1](csharp/whats-new/csharp-7-1.md)
### [What's new in C# 7](csharp/whats-new/csharp-7.md)
### [What's new in C# 6](csharp/whats-new/csharp-6.md)
Expand Down