Skip to content

Commit bb57ca0

Browse files
authored
changed files by pdets auto publish service, publishid[35d4fa7c-4e3a-426b-8d4a-e60bf1545fc4] and do [publish].
1 parent ba38024 commit bb57ca0

10 files changed

+41
-112
lines changed

learn-pr/wwl-language/csharp-format-strings/1-introduction.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Introduction
44
metadata:
55
title: Introduction
66
description: "Introduction"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial

learn-pr/wwl-language/csharp-format-strings/2-string-formatting-basics.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Exercise - Investigate string formatting basics
44
metadata:
55
title: Exercise - Investigate string formatting basics
66
description: "Exercise - Investigate string formatting basics"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial

learn-pr/wwl-language/csharp-format-strings/3-exercise-string-interpolation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Exercise - Explore string interpolation
44
metadata:
55
title: Exercise - Explore string interpolation
66
description: "Exercise - Explore string interpolation"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial

learn-pr/wwl-language/csharp-format-strings/4-exercise-string-methods-padding.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Exercise - Discover padding and alignment
44
metadata:
55
title: Exercise - Discover padding and alignment
66
description: "Exercise - Discover padding and alignment"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial

learn-pr/wwl-language/csharp-format-strings/5-challenge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Exercise - Complete a challenge to apply string interpolation to a form l
44
metadata:
55
title: Exercise - Complete a challenge to apply string interpolation to a form letter
66
description: "Exercise - Complete a challenge to apply string interpolation to a form letter"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial

learn-pr/wwl-language/csharp-format-strings/6-solution.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Review a solution to string interpolation
44
metadata:
55
title: Review a solution to string interpolation
66
description: "Review a solution to string interpolation"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial

learn-pr/wwl-language/csharp-format-strings/7-knowledge-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Knowledge check
44
metadata:
55
title: Knowledge check
66
description: "Knowledge check"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial

learn-pr/wwl-language/csharp-format-strings/8-summary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Summary
44
metadata:
55
title: Summary
66
description: "Summary"
7-
ms.date: 04/19/2023
7+
ms.date: 04/25/2023
88
author: wwlpublish
99
ms.author: eric
1010
ms.topic: interactive-tutorial
Lines changed: 32 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

22

3+
34
The `string.Format()` method is used to perform composite formatting such as in the example:
45

56
```csharp
@@ -26,36 +27,21 @@ The `PadLeft()` method adds blank spaces to the left-hand side of the string so
2627
1. Delete or use the line comment operator `//` to comment out all of the code from the previous exercises.
2728

2829
1. Update your code in the Visual Studio Code Editor as follows:
29-
30-
```csharp
31-
string input = "Pad this";
32-
Console.WriteLine(input.PadLeft(12));
33-
```
30+
```csharp string input = "Pad this"; Console.WriteLine(input.PadLeft(12)); ```
3431

3532
1. On the Visual Studio Code **File** menu, select **Save**.
36-
37-
Save the Program.cs file before building or running the code.
33+
Save the Program.cs file before building or running the code.
3834

3935
1. In the EXPLORER panel, to open a Terminal at your TestProject folder location, right-click **TestProject**, and then select **Open in Integrated Terminal**.
40-
41-
A Terminal panel should open, and should include a command prompt showing that the Terminal is open to your TestProject folder location.
36+
A Terminal panel should open, and should include a command prompt showing that the Terminal is open to your TestProject folder location.
4237

4338
1. At the Terminal command prompt, to run your code, type **dotnet run** and then press Enter.
44-
45-
> [!NOTE]
46-
> If you see a message saying "Couldn't find a project to run", ensure that the Terminal command prompt displays the expected TestProject folder location. For example: `C:\Users\someuser\Desktop\csharpprojects\TestProject>`
47-
48-
When you run the code, you observe four characters prefixed to the left of the string bring the length to 12 characters long.
49-
50-
```Output
51-
Pad this
52-
```
39+
> [!NOTE] > If you see a message saying "Couldn't find a project to run", ensure that the Terminal command prompt displays the expected TestProject folder location. For example: `C:\Users\someuser\Desktop\csharpprojects\TestProject>`
40+
When you run the code, you observe four characters prefixed to the left of the string bring the length to 12 characters long.
41+
```Output Pad this ```
5342

5443
1. To add space or characters to the right side of your string, use the `PadRight()` method instead. 1. Update your code in the Visual Studio Code Editor as follows:
55-
56-
```csharp
57-
Console.WriteLine(input.PadRight(12));
58-
```
44+
```csharp Console.WriteLine(input.PadRight(12)); ```
5945

6046
1. Save your code file, and then use Visual Studio Code to run your code. You won't observe any characters added to the end of the string, but they're there.
6147

@@ -68,22 +54,14 @@ You can also call a second *overloaded* version of the method and pass in whatev
6854
1. Delete or use the line comment operator `//` to comment out all of the code from the previous step.
6955

7056
1. Update your code in the Visual Studio Code Editor as follows:
71-
72-
```csharp
73-
Console.WriteLine(input.PadLeft(12, '-'));
74-
Console.WriteLine(input.PadRight(12, '-'));
75-
```
57+
```csharp Console.WriteLine(input.PadLeft(12, '-')); Console.WriteLine(input.PadRight(12, '-')); ```
7658

7759
1. Save your code file, and then use Visual Studio Code to run your code. You should see four dashes prefixing the left of the string that is 12 characters long.
78-
79-
```Output
80-
----Pad this
81-
Pad this----
82-
```
60+
```Output ----Pad this Pad this---- ```
8361

8462
Now, apply this newfound knowledge to another real world scenario.
8563

86-
## Exercise - Working with padded strings
64+
## Working with padded strings
8765

8866
Suppose you work for a payment processing company that still supports legacy mainframe systems. Often, those systems require data to be input in specific columns. For example, store the Payment ID in columns 1 through 6, the payee's name in columns 7 through 30, and the Payment Amount in columns 31 through 40. Also, importantly, the Payment Amount is right-aligned.
8967

@@ -96,22 +74,13 @@ To get started, print the Payment ID in the first six columns. You pick some ran
9674
1. Delete or use the line comment operator `//` to comment out all of the code from the previous step.
9775

9876
1. Update your code in the Visual Studio Code Editor as follows:
99-
100-
```csharp
101-
string paymentId = "769C";
102-
103-
var formattedLine = paymentId.PadRight(6);
104-
105-
Console.WriteLine(formattedLine);
106-
```
107-
108-
Reuse the `formattedLine` variable to build the output string.
77+
```csharp string paymentId = "769C";
78+
var formattedLine = paymentId.PadRight(6);
79+
Console.WriteLine(formattedLine); ```
80+
Reuse the `formattedLine` variable to build the output string.
10981

11082
1. Save your code file, and then use Visual Studio Code to run your code. You should see the following output:
111-
112-
```Output
113-
769
114-
```
83+
```Output 769 ```
11584

11685
There are three blank spaces to the right that not visible. You'll confirm that they exist in the next step.
11786

@@ -120,28 +89,14 @@ There are three blank spaces to the right that not visible. You'll confirm that
12089
Next, you add a fictitious Payee Name, padding it appropriately.
12190

12291
1. Update your code in the Visual Studio Code Editor as follows:
123-
124-
```csharp
125-
string paymentId = "769";
126-
string payeeName = "Mr. Stephen Ortega";
127-
128-
var formattedLine = paymentId.PadRight(6);
129-
formattedLine += payeeName.PadRight(24);
130-
131-
Console.WriteLine(formattedLine);
132-
```
133-
134-
The `+=` operator performs a string concatenation, taking the previous value of the variable `formattedLine` and adding the new value to it. It's a shortened equivalent the following code example:
135-
136-
```csharp
137-
formattedLine = formattedLine + payeeName.PadRight(24);
138-
```
92+
```csharp string paymentId = "769"; string payeeName = "Mr. Stephen Ortega";
93+
var formattedLine = paymentId.PadRight(6); formattedLine += payeeName.PadRight(24);
94+
Console.WriteLine(formattedLine); ```
95+
The `+=` operator performs a string concatenation, taking the previous value of the variable `formattedLine` and adding the new value to it. It's a shortened equivalent the following code example:
96+
```csharp formattedLine = formattedLine + payeeName.PadRight(24); ```
13997

14098
1. Save your code file, and then use Visual Studio Code to run your code. You should see the following output:
141-
142-
```Output
143-
769 Mr. Stephen Ortega
144-
```
99+
```Output 769 Mr. Stephen Ortega ```
145100

146101
Again, there are quite a few blank spaces after the Payee's Name. Also, there are three blank spaces after the Payment ID from Step 1.
147102

@@ -150,26 +105,14 @@ Again, there are quite a few blank spaces after the Payee's Name. Also, there ar
150105
Next, add a fictitious Payment Amount and make sure to use `PadLeft()` to right-align the output.
151106

152107
1. Update your code in the Visual Studio Code Editor as follows:
153-
154-
```csharp
155-
string paymentId = "769";
156-
string payeeName = "Mr. Stephen Ortega";
157-
string paymentAmount = "$5,000.00";
158-
159-
var formattedLine = paymentId.PadRight(6);
160-
formattedLine += payeeName.PadRight(24);
161-
formattedLine += paymentAmount.PadLeft(10);
162-
163-
Console.WriteLine(formattedLine);
164-
```
108+
```csharp string paymentId = "769"; string payeeName = "Mr. Stephen Ortega"; string paymentAmount = "$5,000.00";
109+
var formattedLine = paymentId.PadRight(6); formattedLine += payeeName.PadRight(24); formattedLine += paymentAmount.PadLeft(10);
110+
Console.WriteLine(formattedLine); ```
165111

166112
1. Save your code file, and then use Visual Studio Code to run your code. You should see the following output:
113+
```Output 769 Mr. Stephen Ortega $5,000.00 ```
167114

168-
```Output
169-
769 Mr. Stephen Ortega $5,000.00
170-
```
171-
172-
This is pretty close to what you understood the legacy system maintainers were looking for.
115+
This output is pretty close to what you understood the legacy system maintainers were looking for.
173116

174117
### Add a line of numbers above the output to more easily confirm the result
175118

@@ -180,26 +123,12 @@ Console.WriteLine("1234567890123456789012345678901234567890");
180123
```
181124

182125
1. Update your code in the Visual Studio Code Editor as follows:
183-
184-
```csharp
185-
string paymentId = "769";
186-
string payeeName = "Mr. Stephen Ortega";
187-
string paymentAmount = "$5,000.00";
188-
189-
var formattedLine = paymentId.PadRight(6);
190-
formattedLine += payeeName.PadRight(24);
191-
formattedLine += paymentAmount.PadLeft(10);
192-
193-
Console.WriteLine("1234567890123456789012345678901234567890");
194-
Console.WriteLine(formattedLine);
195-
```
126+
```csharp string paymentId = "769"; string payeeName = "Mr. Stephen Ortega"; string paymentAmount = "$5,000.00";
127+
var formattedLine = paymentId.PadRight(6); formattedLine += payeeName.PadRight(24); formattedLine += paymentAmount.PadLeft(10);
128+
Console.WriteLine("1234567890123456789012345678901234567890"); Console.WriteLine(formattedLine); ```
196129

197130
1. Save your code file, and then use Visual Studio Code to run your code. You should see the following output, that you can send off to the maintainers of the legacy system to confirm the new integration works correctly:
198-
199-
```Output
200-
1234567890123456789012345678901234567890
201-
769 Mr. Stephen Ortega $5,000.00
202-
```
131+
```Output 1234567890123456789012345678901234567890 769 Mr. Stephen Ortega $5,000.00 ```
203132

204133
Success!
205134

@@ -211,4 +140,4 @@ There's a few important takeaways from this unit.
211140
- The `PadLeft()` and `PadRight()` methods add white space (or optionally, another character) to the total length of a string.
212141
- Use `PadLeft()` to right-align a string.
213142
- Some methods are overloaded, meaning they have multiple versions of the method with different arguments that affect their functionality.
214-
- The `+=` operator concatenates a new string on the right to the existing string on the left.
143+
- The `+=` operator concatenates a new string on the right to the existing string on the left.

learn-pr/wwl-language/csharp-format-strings/index.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uid: learn.languages.csharp-format-strings
33
metadata:
44
title: Format alphanumeric data for presentation in C#
55
description: "Format alphanumeric data for presentation in C#"
6-
ms.date: 04/19/2023
6+
ms.date: 04/25/2023
77
author: wwlpublish
88
ms.author: eric
99
ms.topic: interactive-tutorial

0 commit comments

Comments
 (0)