Skip to content

Commit 53cd5e1

Browse files
committed
fix warnings
1 parent daac7e5 commit 53cd5e1

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

docs/csharp/tour-of-csharp/tutorials/numbers-in-csharp.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ This tutorial teaches you about the numeric types in C#. You write small amounts
99

1010
## Explore integer math
1111

12-
## Explore integer math
13-
1412
Create a directory named *numbers-quickstart*. Make it the current directory and run the following command:
1513

1614
```dotnetcli

docs/csharp/tour-of-csharp/tutorials/pattern-matching.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ else
5252

5353
The `else if` clause never matches because every number less than 10 is also less than 20. The `switch` expression ensures both of those characteristics are met, which results in fewer bugs in your apps. Let's try it and experiment. Copy the following code. Replace the two `if` statements in your `foreach` loop with the `switch` expression you copied. After you've modified the code, type `dotnet run` to run the new sample.
5454

55-
:::code language="csharp" source="./snippets/PatternMatching/EnumSwitchExample.cs" id="SwitchEnumValue":::
55+
:::code language="csharp" source="./snippets/PatternMatching/Program.cs" id="SwitchEnumValue":::
5656

5757
When you run the code, you see that it works the same. To demonstrate *subsumption*, reorder the switch arms as shown in the following snippet:
5858

@@ -73,15 +73,15 @@ The compiler issues a warning if the expression tested in a `switch` expression
7373

7474
To finish this tutorial, let's explore one more building block to pattern matching: the *type pattern*. A *type pattern* tests an expression at run time to see if it's the specified type. You can use a type test with either an `is` expression or a `switch` expression. Let's modify the current sample in two ways. First, instead of a tuple, let's build `Deposit` and `Withdrawal` record types that represent the transactions. Add the following declarations just at the end of the your code file:
7575

76-
:::code language="csharp" source="./snippets/PatternMatching/FinalExampleProgram.cs" id="RecordDeclarations":::
76+
:::code language="csharp" source="./snippets/PatternMatching/Program.cs" id="RecordDeclarations":::
7777

7878
Next, add this method just before the declaration of the `TransactionType` enumeration. It parses the text and return a series of records:
7979

80-
:::code language="csharp" source="./snippets/PatternMatching/FinalExampleProgram.cs" id="ParseToRecord":::
80+
:::code language="csharp" source="./snippets/PatternMatching/Program.cs" id="ParseToRecord":::
8181

8282
Finally, add the following code after the last `foreach` loop:
8383

84-
:::code language="csharp" source="./snippets/PatternMatching/FinalExampleProgram.cs" id="TypePattern":::
84+
:::code language="csharp" source="./snippets/PatternMatching/Program.cs" id="TypePattern":::
8585

8686
Then, type `dotnet run` to see the results. This final version tests the input against a *type*.
8787

docs/csharp/tour-of-csharp/tutorials/tuples-and-types.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,27 @@ Tuples are great for those times when you want multiple values in the same struc
4848

4949
The following code declares and uses a `record` type to represent a `Point`:
5050

51-
:::code language="csharp" source="./snippets/TuplesAndTypes/PointEvolution.cs" id="PointRecord":::
51+
:::code language="csharp" source="./snippets/TuplesAndTypes/Program.cs" id="PointRecord":::
5252

5353
The preceding code must be at the bottom of your source file. Type declarations like `record` declarations must follow executable statements in a file-based app.
5454

5555
Add the following code preceding the `record` declaration:
5656

57-
:::code language="csharp" source="./snippets/TuplesAndTypes/PointEvolution.cs" id="UsePointRecord":::
57+
:::code language="csharp" source="./snippets/TuplesAndTypes/Program.cs" id="UsePointRecord":::
5858

5959
The `record` declaration is a single line of code for the `Point` type that stores the values `X` and `Y` in readonly properties. You use the name `Point` wherever you use that type. Properly named types, like `Point`, provide information about how the type is used. The additional code shows how to use a `with` expression to create a new point that's a modified copy of the existing point. The line `pt4 = pt3 with { Y = 10 }` says "`pt4` has the same values as `pt3` except that `Y` is assigned to 10." You can add any number of properties to change in a single `with` expression.
6060

6161
The preceding `record` declaration is a single line of code that ends in `;`. You can add behavior to a `record` type by declaring *members*. A record member can be a function, or more data elements. The members of a type are in the type declaration, between `{` and `}` characters. Delete the `;` and add the following lines of code after the `record` declaration:
6262

63-
:::code language="csharp" source="./snippets/TuplesAndTypes/PointStruct.cs" id="AddSlopeMethod":::
63+
:::code language="csharp" source="./snippets/TuplesAndTypes/Program.cs" id="AddSlopeMethod":::
6464

6565
Then, add the following code before the `record` declaration, after the line containing the `with` expression:
6666

67-
:::code language="csharp" source="./snippets/TuplesAndTypes/PointStruct.cs" id="UseSlope":::
67+
:::code language="csharp" source="./snippets/TuplesAndTypes/Program.cs" id="UseSlope":::
6868

6969
You added formality to the *tuple* representing an `X` and `Y` value. You made it a `record` that defined a named type, and included a member to calculate the slope. A `record` type is a shorthand for a `record class`: A `class` type that includes extra behavior. You can modify the `Point` type to make it a `record struct` as well:
7070

71-
:::code language="csharp" source="./snippets/TuplesAndTypes/PointStruct.cs" id="RecordStructPoint":::
71+
:::code language="csharp" source="./snippets/TuplesAndTypes/Program.cs" id="RecordStructPoint":::
7272

7373
A `record struct` is a `struct` type that includes the extra behavior added to all `record` types.
7474

0 commit comments

Comments
 (0)