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: learn-pr/language/dotnet-files/includes/9-exercise-read-write-files.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ In this exercise, you complete the project by reading the .json files, adding up
26
26
record SalesData (double Total);
27
27
```
28
28
29
-
## Create a method to calculate sales totals
29
+
## Create a method that calculates sales totals
30
30
31
31
1. In `Program.cs`, just before the `record` line that you added in the previous step, create a new functionthat calculates the sales total. This method should take an `IEnumerable<string>` of file paths that it can iterate over.
32
32
@@ -55,7 +55,7 @@ In this exercise, you complete the project by reading the .json files, adding up
55
55
string salesJson = File.ReadAllText(file);
56
56
57
57
// Parse the contents as JSON
58
-
SalesData? data = JsonSerializer.Deserialize<SalesData?>(salesJson);
58
+
SalesData? data = JsonConvert.DeserializeObject<SalesData?>(salesJson);
59
59
60
60
// Add the amount found in the Total field to the salesTotal variable
61
61
salesTotal += data?.Total ?? 0;
@@ -101,7 +101,7 @@ In this exercise, you complete the project by reading the .json files, adding up
1. Press <kbd>Ctrl+S</kbd> / <kbd>Cmd+S</kbd> to save the *Program.cs* file.
104
+
1. Save the *Program.cs* file by pressing <kbd>Ctrl+S</kbd> / <kbd>Cmd+S</kbd>.
105
105
106
106
## Run the program
107
107
@@ -123,7 +123,7 @@ In this exercise, you complete the project by reading the .json files, adding up
123
123
124
124
The *totals.txt* file now has a second line. Every time you run the program, the totals are added up again and a new line is written to the file.
125
125
126
-
Outstanding work! You've written a smart, robust, and handy tool that Tailwind Traders can use to process all of its stores' sales every night. In the next unit, we'll review what you learned and a few tips to remember.
126
+
Outstanding work! You wrote a smart, robust, and handy tool that Tailwind Traders can use to process all of its stores' sales every night. In the next unit, we'll review what you learned and a few tips to remember.
0 commit comments