Skip to content

Commit 5102164

Browse files
authored
Respond to feedback. (dotnet#10646)
* Respond to feedback. Useful feedback from @pkulikov came in on PR dotnet#10628 after I had merged it. This PR addresses those comments. See [here](dotnet#10628 (comment)) * Update docs/csharp/whats-new/csharp-8.md Co-Authored-By: BillWagner <wiwagn@microsoft.com>
1 parent 71e4d7d commit 5102164

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/csharp/whats-new/csharp-8.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,23 @@ int M()
241241
int x = 7;
242242
return Add(x, y);
243243

244-
int Add(int left, int right) => left + right;
244+
static int Add(int left, int right) => left + right;
245245
}
246246
```
247247

248248
## Disposable ref structs
249249

250-
A `struct` declared with the `ref` modifier may not implement any interfaces and so cannot implement <xref:System.IDisposable>. Therefore, to enable a `ref struct` to be disposed, it must have an accessible `void Dispose()` method.
250+
A `struct` declared with the `ref` modifier may not implement any interfaces and so cannot implement <xref:System.IDisposable>. Therefore, to enable a `ref struct` to be disposed, it must have an accessible `void Dispose()` method. This also applies to `readonly ref struct` declarations.
251251

252252
## Nullable reference types
253253

254254
Inside a nullable annotation context, any variable of a reference type is considered to be a **nonnullable reference type**. If you want to indicate that a variable may be null, you must append the type name with the `?` to declare the variable as a **nullable reference type**.
255255

256-
For nonnullable reference types, the compiler uses flow analysis to ensure that local variables are initialized to a non-null value when declared. Fields must be initialized during construction. The compiler generates a warning if the variable is not set in all constructors, or an initializer. Furthermore, nonnullable reference types can't be assigned a value that could be null.
256+
For nonnullable reference types, the compiler uses flow analysis to ensure that local variables are initialized to a non-null value when declared. Fields must be initialized during construction. The compiler generates a warning if the variable is not set by a call to any of the available constructors or by an initializer. Furthermore, nonnullable reference types can't be assigned a value that could be null.
257257

258258
Nullable reference types aren't checked to ensure they aren't assigned or initialized to null. However, the compiler uses flow analysis to ensure that any variable of a nullable reference type is checked against null before it's accessed or assigned to a nonnullable reference type.
259259

260-
You can learn more about the feature in the overview of [nullable reference types](../nullable-references.md). Try it yourself in a new application in this [nullable reference types tutorial](../tutorials/nullable-reference-types.md). Learn about the steps to migrate an existing codebase to make use of nullable reference types in the [migrating an application to use nullable reference types tutorial]../tutorials/upgrade-to-nullable-references.md).
260+
You can learn more about the feature in the overview of [nullable reference types](../nullable-references.md). Try it yourself in a new application in this [nullable reference types tutorial](../tutorials/nullable-reference-types.md). Learn about the steps to migrate an existing codebase to make use of nullable reference types in the [migrating an application to use nullable reference types tutorial](../tutorials/upgrade-to-nullable-references.md).
261261

262262
## Asynchronous streams
263263

@@ -295,7 +295,7 @@ You can try asynchronous streams yourself in our tutorial on [creating and consu
295295

296296
Ranges and indices provide a succinct syntax for specifying subranges in an array, <xref:System.Span%601>, or <xref:System.ReadOnlySpan%601>.
297297

298-
You can specify an index **from the end**. You specify **from the end** using the `^` operator. You are familiar with `array[2]` meaning the element "2 from the start". Now, `array[^2]` means the element "2 from the end". The index `^0` means "the end", or one past that last element.
298+
You can specify an index **from the end**. You specify **from the end** using the `^` operator. You are familiar with `array[2]` meaning the element "2 from the start". Now, `array[^2]` means the element "2 from the end". The index `^0` means "the end", or the index that follows the last element.
299299

300300
You can specify a **range** with the **range operator**: `..`. For example, `0..^0` specifies the entire range of the array: 0 from the start up to, but not including 0 from the end. Either operand may use "from the start" or "from the end". Furthermore, either operand may be omitted. The defaults are `0` for the start index, and `^0` for the end index.
301301

0 commit comments

Comments
 (0)