Skip to content

Commit efb1e65

Browse files
committed
Notes and a test build.
1 parent 682d700 commit efb1e65

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

docs/csharp/tutorials/exploration/csharp-7.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ items:
2424
2525
You can now declare `out` variables in the argument list of a method call, rather than writing a separate declaration statement:
2626
27+
IN OTHER FILE AS WELL
2728
[!code-csharp[OutVariableDeclarations](~/samples/snippets/csharp/new-in-7/program.cs#01_OutVariableDeclarations "Out variable declarations")]
2829
2930
You may want to specify the type of the `out` variable for clarity, as shown above. However, the language does support using an implicitly typed local variable:
3031
32+
IN OTHER FILE AS WELL
3133
[!code-csharp[OutVarVariableDeclarations](~/samples/snippets/csharp/new-in-7/program.cs#02_OutVarVariableDeclarations "Implicitly typed Out variable")]
3234
3335
* The code is easier to read.
@@ -75,12 +77,14 @@ items:
7577
7678
That assignment creates a tuple whose members are `Item1` and `Item2`, which you can use in the same way as <xref:System.Tuple> You can change the syntax to create a tuple that provides semantic names to each of the members of the tuple:
7779
80+
USED IN OTHER FILE
7881
[!code-csharp[NamedTuple](~/samples/snippets/csharp/new-in-7/program.cs#05_NamedTuple "Named tuple")]
7982
8083
The `namedLetters` tuple contains fields referred to as `Alpha` and `Beta`. Those names exist only at compile time and are not preserved when inspecting the tuple using reflection at runtime, for example.
8184
8285
In a tuple assignment, you can also specify the names of the fields on the right-hand side of the assignment:
8386
87+
USED IN OTHER FILE
8488
[!code-csharp[ImplicitNamedTuple](~/samples/snippets/csharp/new-in-7/program.cs#06_ImplicitNamedTuple "Implicitly named tuple")]
8589
8690
You can specify names for the fields on both the left and right-hand side of the assignment:
@@ -107,6 +111,7 @@ items:
107111
108112
There may be times when you want to unpackage the members of a tuple that were returned from a method. You can do that by declaring separate variables for each of the values in the tuple. This is called *deconstructing* the tuple:
109113
114+
USED IN OTHER FILE
110115
[!code-csharp[CallingWithDeconstructor](~/samples/snippets/csharp/new-in-7/program.cs#10_CallingWithDeconstructor "Deconstructing a tuple")]
111116
112117
You can also provide a similar deconstruction for any type in .NET. This is
@@ -116,10 +121,12 @@ items:
116121
this `Point` class that provides a deconstructor method that extracts
117122
the `X` and `Y` coordinates:
118123
124+
USED IN OTHER FILE
119125
[!code-csharp[PointWithDeconstruction](~/samples/snippets/csharp/new-in-7/point.cs#11_PointWithDeconstruction "Point with deconstruction method")]
120126
121127
You can extract the individual fields by assigning a `Point` to a tuple:
122128
129+
USED IN OTHER FILE
123130
[!code-csharp[DeconstructPoint](~/samples/snippets/csharp/new-in-7/program.cs#12_DeconstructPoint "Deconstruct a point")]
124131
125132
You are not bound by the names defined in the `Deconstruct` method. You
@@ -147,6 +154,7 @@ items:
147154
148155
The following example defines a `QueryCityDataForYears` method that returns a 6-tuple that contains data for a city for two different years. The method call in the example is concerned only with the two population values returned by the method and so treats the remaining values in the tuple as discards when it deconstructs the tuple.
149156
157+
USED IN OTHER FILE
150158
[!code-csharp[Tuple-discard](~/samples/snippets/csharp/programming-guide/deconstructing-tuples/discard-tuple1.cs)]
151159
152160
For more information, see [Discards](../../discards.md).
@@ -307,6 +315,7 @@ items:
307315
by reference, and helps developers reading the code later remember that
308316
the method returns by reference:
309317
318+
USED IN OTHER FILE
310319
[!code-csharp[FindReturningRef](~/samples/snippets/csharp/new-in-7/MatrixSearch.cs#22_FindReturningRef "Find returning by reference")]
311320
312321
Now that the method returns a reference to the integer value in the
@@ -326,6 +335,7 @@ items:
326335
to the local variable declaration to make the variable a reference when
327336
the return value is a reference:
328337
338+
USED IN OTHER FILE
329339
[!code-csharp[AssignRefReturn](~/samples/snippets/csharp/new-in-7/program.cs#24_AssignRefReturn "Assign ref return")]
330340
331341
Now, the second `WriteLine` statement in the example above prints
@@ -404,6 +414,7 @@ items:
404414
`alphabetSubsetImplementation` as a local function inside the public
405415
API method:
406416
417+
USED IN OTHER FILE
407418
[!code-csharp[22_IteratorMethodLocal](~/samples/snippets/csharp/new-in-7/Iterator.cs#28_IteratorMethodLocal "Iterator method with local function")]
408419
409420
The version above makes it clear that the local method is referenced
@@ -415,6 +426,7 @@ items:
415426
exceptions arising from argument validation are thrown before the asynchronous
416427
work begins:
417428
429+
USED IN OTHER FILE
418430
[!code-csharp[TaskExample](~/samples/snippets/csharp/new-in-7/AsyncWork.cs#29_TaskExample "Task returning method with local function")]
419431
420432
> [!NOTE]
@@ -475,21 +487,24 @@ items:
475487
Binary numbers can get very long, so it's often easier to see
476488
the bit patterns by introducing the `_` as a digit separator:
477489
490+
USED IN OTHER FILE
478491
[!code-csharp[ThousandSeparators](~/samples/snippets/csharp/new-in-7/Program.cs#33_ThousandSeparators "Thousands separators")]
479492
480493
The digit separator can appear anywhere in the constant. For base 10
481494
numbers, it would be common to use it as a thousands separator:
482495
496+
USED IN OTHER FILE
483497
[!code-csharp[LargeIntegers](~/samples/snippets/csharp/new-in-7/Program.cs#34_LargeIntegers "Large integer")]
484498
485499
The digit separator can be used with `decimal`, `float` and `double`
486500
types as well:
487501
502+
USED IN OTHER FILE
488503
[!code-csharp[OtherConstants](~/samples/snippets/csharp/new-in-7/Program.cs#35_OtherConstants "non-integral constants")]
489504
490505
Taken together, you can declare numeric constants with much more
491506
readability.
492507
493508
- content: |
494-
You've completed an exploration of the new features in C# 6. Now try them yourself in your applications.
509+
You've completed an exploration of the new features in C# 7. Now try them yourself in your applications.
495510

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ The fields aren't validated, and you cannot define your own methods
7272
You can create a tuple by assigning a value to each member, and optionally providing semantic
7373
names to each of the members of the tuple:
7474

75-
[!code-csharp[NamedTuple](../../../samples/snippets/csharp/new-in-7/program.cs#05_NamedTuple "Named tuple")]
75+
[!code-csharp[NamedTuple](~/samples/snippets/csharp/new-in-7/program.cs#05_NamedTuple "Named tuple")]
7676

7777
The `namedLetters` tuple contains fields referred to as `Alpha` and
7878
`Beta`. Those names exist only at compile time and aren't preserved,
@@ -81,25 +81,25 @@ for example when inspecting the tuple using reflection at runtime.
8181
In a tuple assignment, you can also specify the names of the fields
8282
on the right-hand side of the assignment:
8383

84-
[!code-csharp[ImplicitNamedTuple](../../../samples/snippets/csharp/new-in-7/program.cs#06_ImplicitNamedTuple "Implicitly named tuple")]
84+
[!code-csharp[ImplicitNamedTuple](~/samples/snippets/csharp/new-in-7/program.cs#06_ImplicitNamedTuple "Implicitly named tuple")]
8585

8686
There may be times when you want to unpackage the members of a tuple that
8787
were returned from a method. You can do that by declaring separate variables
8888
for each of the values in the tuple. This unpackaging is called *deconstructing* the tuple:
8989

90-
[!code-csharp[CallingWithDeconstructor](../../../samples/snippets/csharp/new-in-7/program.cs#10_CallingWithDeconstructor "Deconstructing a tuple")]
90+
[!code-csharp[CallingWithDeconstructor](~/samples/snippets/csharp/new-in-7/program.cs#10_CallingWithDeconstructor "Deconstructing a tuple")]
9191

9292
You can also provide a similar deconstruction for any type in .NET. You write a `Deconstruct` method as a member of the class. That
9393
`Deconstruct` method provides a set of `out` arguments for each of the
9494
properties you want to extract. Consider
9595
this `Point` class that provides a deconstructor method that extracts
9696
the `X` and `Y` coordinates:
9797

98-
[!code-csharp[PointWithDeconstruction](../../../samples/snippets/csharp/new-in-7/point.cs#11_PointWithDeconstruction "Point with deconstruction method")]
98+
[!code-csharp[PointWithDeconstruction](~/samples/snippets/csharp/new-in-7/point.cs#11_PointWithDeconstruction "Point with deconstruction method")]
9999

100100
You can extract the individual fields by assigning a `Point` to a tuple:
101101

102-
[!code-csharp[DeconstructPoint](../../../samples/snippets/csharp/new-in-7/program.cs#12_DeconstructPoint "Deconstruct a point")]
102+
[!code-csharp[DeconstructPoint](~/samples/snippets/csharp/new-in-7/program.cs#12_DeconstructPoint "Deconstruct a point")]
103103

104104
You can learn more in depth about tuples in the
105105
[tuples article](../tuples.md).
@@ -117,7 +117,7 @@ Discards are supported in the following scenarios:
117117

118118
The following example defines a `QueryCityDataForYears` method that returns a 6-tuple that contains a data for a city for two different years. The method call in the example is concerned only with the two population values returned by the method and so treats the remaining values in the tuple as discards when it deconstructs the tuple.
119119

120-
[!code-csharp[Tuple-discard](../../../samples/snippets/csharp/programming-guide/deconstructing-tuples/discard-tuple1.cs)]
120+
[!code-csharp[Tuple-discard](~/samples/snippets/csharp/programming-guide/deconstructing-tuples/discard-tuple1.cs)]
121121

122122
For more information, see [Discards](../discards.md).
123123

@@ -267,7 +267,7 @@ members that can be implemented as expressions. In C# 7.0, you can implement
267267
*constructors*, *finalizers*, and `get` and `set` accessors on *properties*
268268
and *indexers*. The following code shows examples of each:
269269

270-
[!code-csharp[ExpressionBodiedMembers](../../../samples/snippets/csharp/new-in-7/expressionmembers.cs#36_ExpressionBodiedEverything "new expression-bodied members")]
270+
[!code-csharp[ExpressionBodiedMembers](~/samples/snippets/csharp/new-in-7/expressionmembers.cs#36_ExpressionBodiedEverything "new expression-bodied members")]
271271

272272
> [!NOTE]
273273
> This example does not need a finalizer, but it is shown
@@ -311,7 +311,7 @@ must be accessible. As one concrete example, the `ValueTask` type
311311
has been added to the .NET framework to make use of this new language
312312
feature:
313313

314-
[!code-csharp[UsingValueTask](../../../samples/snippets/csharp/new-in-7/AsyncWork.cs#30_UsingValueTask "Using ValueTask")]
314+
[!code-csharp[UsingValueTask](~/samples/snippets/csharp/new-in-7/AsyncWork.cs#30_UsingValueTask "Using ValueTask")]
315315

316316
> [!NOTE]
317317
> You need to add the NuGet package [`System.Threading.Tasks.Extensions`](https://www.nuget.org/packages/System.Threading.Tasks.Extensions/)

0 commit comments

Comments
 (0)