You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/csharp/whats-new/csharp-7-3.md
+44-22Lines changed: 44 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,68 +45,90 @@ unsafe struct S
45
45
}
46
46
```
47
47
48
-
In earlier versions of C#, you needed to pin a variable to access one of the integers that are part of `myFixedField`. Now, the following code compiles:
48
+
In earlier versions of C#, you needed to pin a variable to access one of the integers that are part of `myFixedField`. Now, the following code compiles in a safe context:
49
49
50
50
```csharp
51
-
vars=newS();
52
-
intp=s.myFixedField[5];
51
+
classC
52
+
{
53
+
staticSs=newS();
54
+
55
+
publicvoidM()
56
+
{
57
+
intp=s.myFixedField[5];
58
+
}
59
+
}
53
60
```
54
61
55
-
The variable `p` doesn't need to be pinned. Note that you still need an `unsafe` context.
62
+
The variable `p` doesn't need to be pinned. Note that you still need an `unsafe` context. In earlier versions of C#, you need to declare a second fixed pointer:
56
63
57
-
You can learn more in the article on the [`fixed` statement](../language-reference/keywords/fixed-statement.md).
64
+
```csharp
65
+
classC
66
+
{
67
+
staticSs=newS();
68
+
69
+
publicvoidM()
70
+
{
71
+
fixed (int*ptr=s.myFixedField)
72
+
{
73
+
intp=ptr[5];
74
+
}
75
+
}
76
+
}
77
+
```
78
+
79
+
Fore more information, see the article on the [`fixed` statement](../language-reference/keywords/fixed-statement.md).
58
80
59
81
### `ref` local variables may be reassigned
60
82
61
-
Now, `ref` locals may be reassigned to refer to different storage after being initialized. The following code now compiles:
83
+
Now, `ref` locals may be reassigned to refer to different instances after being initialized. The following code now compiles:
refLocal=refanotherVeryLargeStruct; // reassigned, refLocal refers to different storage.
66
88
```
67
89
68
-
You can learn more in the article on [`ref` returns and `ref` locals](../programming-guide/classes-and-structs/ref-returns.md).
90
+
For more information, see the article on [`ref` returns and `ref` locals](../programming-guide/classes-and-structs/ref-returns.md).
69
91
70
92
### `stackalloc` arrays support initializers
71
93
72
-
You have been able to specify the values for elements in an array when you initialize the array:
94
+
You've been able to specify the values for elements in an array when you initialize it:
73
95
74
96
```csharp
75
97
vararr=newint[3] {1, 2, 3};
76
-
vararr2=newint[] {1, 2, 3};
98
+
vararr2=newint[] {1, 2, 3};
77
99
```
78
100
79
101
Now, that same syntax can be applied to arrays that are declared with `stackalloc`:
80
102
81
103
```csharp
82
104
int*pArr=stackallocint[3] {1, 2, 3};
83
-
int*pArr2=stackallocint[] {1, 2, 3};
105
+
int*pArr2=stackallocint[] {1, 2, 3};
84
106
Span<int>arr=stackalloc [] {1, 2, 3};
85
107
```
86
108
87
-
You can learn more in the article on the [`stackalloc` statement](../language-reference/keywords/stackalloc.md).
109
+
For more information, see the [`stackalloc` statement](../language-reference/keywords/stackalloc.md) article in the language reference.
88
110
89
111
### More types support the `fixed` statement
90
112
91
113
The `fixed` statement supported a limited set of types. Starting with C# 7.3, any type that contains a `DangerousGetPinnableReference()` method that returns a `ref T` or `ref readonly T` may be `fixed`. Adding this feature means that `fixed` can be used with <xref:System.Span%601?displayProperty=nameWithType> and related types.
92
114
93
-
You can learn more in the article on the [`fixed` statement](../language-reference/keywords/fixed-statement.md).
115
+
For more information, see the [`fixed` statement](../language-reference/keywords/fixed-statement.md) article in the language reference.
94
116
95
117
### Enhanced generic constraints
96
118
97
119
You can now specify the type <xref:System.Enum?displayProperty=nameWithType> or <xref:System.Delegate?displayProperty=nameWithType> as base class constraints for a type parameter.
98
120
99
-
You can also use the new `unmanaged` constraint, to specify that a type parameter must be an **unmanaged type**. An **unmanaged type** is a type that isn't a reference type, and doesn't contain any reference type at any level of nesting.
121
+
You can also use the new `unmanaged` constraint, to specify that a type parameter must be an **unmanaged type**. An **unmanaged type** is a type that isn't a reference type and doesn't contain any reference type at any level of nesting.
100
122
101
-
You can learn more in the articles on [`where` generic constraints](../language-reference/keywords/where-generic-type-constraints.md) and the article covering[constraints on type parameters](../programming-guide/generics/constraints-on-type-parameters.md).
123
+
For more information, see the articles on [`where` generic constraints](../language-reference/keywords/where-generic-type-constraint.md) and [constraints on type parameters](../programming-guide/generics/constraints-on-type-parameters.md).
102
124
103
125
## Make existing features better
104
126
105
127
The second theme provides improvements to features in the language. These features improve productivity when writing C#.
106
128
107
129
### Tuples support `==` and `!=`
108
130
109
-
The C# tuple types now support `==` and `!=`. You can learn more about the rules in the article on [tuples](../tuples.md#equality-and-tuples).
131
+
The C# tuple types now support `==` and `!=`. Fore more information, see the section covering [equality](../tuples.md#equality-and-tuples) in the article on [tuples](../tuples.md#equality-and-tuples).
110
132
111
133
### Attach attributes to the backing fields for auto-implemented properties
112
134
@@ -117,7 +139,7 @@ This syntax is now supported:
117
139
publicintSomeProperty { get; set; }
118
140
```
119
141
120
-
The attribute `SomeThingAboutFieldAttribute` is applied to the compiler generated backing field for `SomeProperty`. You can learn more in the articles on [attributes in C#](../programming-guide/concepts/attributes/index.md).
142
+
The attribute `SomeThingAboutFieldAttribute` is applied to the compiler generated backing field for `SomeProperty`. For more information, see [attributes](../programming-guide/concepts/attributes/index.md) in the C# programming guide.
121
143
122
144
### `in` method overload resolution tiebreaker
123
145
@@ -128,7 +150,7 @@ static void M(S arg);
128
150
staticvoidM(inSarg);
129
151
```
130
152
131
-
Now, the by value (first in the preceding example) overload is better than the by readonly reference version. To specify the by readonly reference version is called, you must include the `in` modifier when calling the method.
153
+
Now, the by value (first in the preceding example) overload is better than the by readonly reference version. To call the version with the readonly reference argument, you must include the `in` modifier when calling the method.
132
154
133
155
> [!NOTE]
134
156
> This was implemented as a bug fix. This no longer is ambiguous even with the language version set to "7.2".
@@ -137,7 +159,7 @@ For more information, see the article on the [`in` parameter modifier](../langua
137
159
138
160
### Extend expression variables in initializers
139
161
140
-
The syntax added in C# 7.0 to permit out variable declarations has been extended to include field initializers, property initializers, constructor initializers, and query clauses. It enables code such as the following example:
162
+
The syntax added in C# 7.0 to aloow `out` variable declarations has been extended to include field initializers, property initializers, constructor initializers, and query clauses. It enables code such as the following example:
141
163
142
164
```csharp
143
165
publicclassB
@@ -169,16 +191,16 @@ You'll only notice this change because you'll find fewer compiler errors for amb
169
191
170
192
## New compiler options
171
193
172
-
New compiler options support new build and DevOps scenarios for C# programs
194
+
New compiler options support new build and DevOps scenarios for C# programs.
173
195
174
-
### Public or OSS signing
196
+
### Public or Open Source signing
175
197
176
198
The `-publicsign` compiler option instructs the compiler to sign the assembly using a public key. The assembly is marked as signed, but the signature is taken from the public key. This option enables you to build signed assemblies from open-source projects using a public key.
177
199
178
200
For more information, see the [-publicsign compiler option](../language-reference/compiler-options/publicsign-compiler-option.md) article.
179
201
180
202
### pathmap
181
203
182
-
The `-pathmap` compiler option instructs the compiler to replace source paths from the build environment with mapped source paths. The pathmap option controls the source path written by the compiler to PDB files or for the <xref:System.Runtime.CompilerServices.CallerFilePathAttribute>.
204
+
The `-pathmap` compiler option instructs the compiler to replace source paths from the build environment with mapped source paths. The `pathmap` option controls the source path written by the compiler to PDB files or for the <xref:System.Runtime.CompilerServices.CallerFilePathAttribute>.
183
205
184
206
For more information, see the [-pathmap compiler option](../language-reference/compiler-options/pathmap-compile-option.md) article.
Copy file name to clipboardExpand all lines: docs/csharp/whats-new/index.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,10 @@ the C# language. The following links provide detailed information on the
12
12
major features added in each release.
13
13
14
14
> [!IMPORTANT]
15
-
> 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.
15
+
> 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. For more information, see the article on the [relationships between language and library](relationships-between-language-and-library.md) for background on this dependency.
16
16
17
17
*[C# 7.3](csharp-7-3.md):
18
-
- This page describes the latest features in the C# language. C# 7.3 is currently available in [Visual Studio 2017 version 15.7](https://www.visualstudio.com/vs/whatsnew/), and in the [.NET Core 2.1 SDK Preview](../../core/whats-new/index.md).
18
+
- This page describes the latest features in the C# language. C# 7.3 is currently available in [Visual Studio 2017 version 15.7](https://www.visualstudio.com/vs/whatsnew/), and in the [.NET Core 2.1 SDK 2.1.300 RC1](../../core/whats-new/index.md).
19
19
*[C# 7.2](csharp-7-2.md):
20
20
- This page describes the features added 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).
0 commit comments