Skip to content

Commit 48c3819

Browse files
authored
Merge pull request #50959 from wwlpublish/ae918d11e12925c1fe2521c1f385b84d5f2e6f96d26db8543be33e964c0a598b-live
Modules/M04-iterate-through-code-block-using-for-statement-c-sharp
2 parents 21651ad + 98d0f10 commit 48c3819

11 files changed

+63
-22
lines changed

.openpublishing.redirection.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48748,6 +48748,16 @@
4874848748
"source_path": "learn-pr/wwl-language/csharp-switch-case/4-solution.md",
4874948749
"redirect_url": "/training/modules/csharp-switch-case/4-review-solution-switch-statements-challenge",
4875048750
"redirect_document_id": false
48751+
},
48752+
{
48753+
"source_path": "learn-pr/wwl-language/csharp-for/3-challenge.md",
48754+
"redirect_url": "/training/modules/csharp-for/3-exercise-challenge-for-statements",
48755+
"redirect_document_id": false
48756+
},
48757+
{
48758+
"source_path": "learn-pr/wwl-language/csharp-for/4-solution.md",
48759+
"redirect_url": "/training/modules/csharp-for/4-review-solution-for-statements-challenge",
48760+
"redirect_document_id": false
4875148761
}
4875248762
]
4875348763
}

learn-pr/wwl-language/csharp-for/1-introduction.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Introduction
44
metadata:
55
title: Introduction
66
description: "Introduction"
7-
ms.date: 02/22/2024
7+
ms.date: 06/17/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 3
1214
content: |
1315
[!include[](includes/1-introduction.md)]

learn-pr/wwl-language/csharp-for/2-exercise-for.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Exercise - Create and configure for iteration loops
44
metadata:
55
title: Exercise - Create and configure for iteration loops
66
description: "Exercise - Create and configure for iteration loops"
7-
ms.date: 02/22/2024
7+
ms.date: 06/17/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 14
1214
content: |
1315
[!include[](includes/2-exercise-for.md)]

learn-pr/wwl-language/csharp-for/3-challenge.yml renamed to learn-pr/wwl-language/csharp-for/3-exercise-challenge-for-statements.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Exercise - Complete a challenge activity using for and if statements
44
metadata:
55
title: Exercise - Complete a challenge activity using for and if statements
66
description: "Exercise - Complete a challenge activity using for and if statements"
7-
ms.date: 02/22/2024
7+
ms.date: 06/17/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 9
1214
content: |
13-
[!include[](includes/3-challenge.md)]
15+
[!include[](includes/3-exercise-challenge-for-statements.md)]

learn-pr/wwl-language/csharp-for/4-solution.yml renamed to learn-pr/wwl-language/csharp-for/4-review-solution-for-statements-challenge.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Review the solution to the for and if statement challenge activity
44
metadata:
55
title: Review the solution to the for and if statement challenge activity
66
description: "Review the solution to the for and if statement challenge activity"
7-
ms.date: 02/22/2024
7+
ms.date: 06/17/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 6
1214
content: |
13-
[!include[](includes/4-solution.md)]
15+
[!include[](includes/4-review-solution-for-statements-challenge.md)]

learn-pr/wwl-language/csharp-for/5-knowledge-check.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Module assessment
44
metadata:
55
title: Module assessment
66
description: "Knowledge check"
7-
ms.date: 02/22/2024
7+
ms.date: 06/17/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 3
1214
quiz:
1315
title: "Check your knowledge"

learn-pr/wwl-language/csharp-for/6-summary.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ title: Summary
44
metadata:
55
title: Summary
66
description: "Summary"
7-
ms.date: 02/22/2024
7+
ms.date: 06/17/2025
88
author: wwlpublish
99
ms.author: cahowd
1010
ms.topic: unit
11+
ms.custom:
12+
- N/A
1113
durationInMinutes: 2
1214
content: |
1315
[!include[](includes/6-summary.md)]

learn-pr/wwl-language/csharp-for/includes/2-exercise-for.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
On the surface, the `for` statement is another iteration statement that allows you to iterate through a code block and thereby change the flow of execution of your code. However, once we examine how each works, we can better identify the nuances of each iteration statement and when to use them.
23

34
## What is the `for` statement?
@@ -22,7 +23,7 @@ This module includes hands-on activities that guide you through the process of b
2223

2324
1. In the **Open Folder** dialog, navigate to the Windows Desktop folder.
2425

25-
If you have different folder location where you keep code projects, you can use that folder location instead. For this training, the important thing is to have a location that’s easy locate and remember.
26+
If you have a different folder location where you keep code projects, you can use that folder location instead. For this training, the important thing is to have a location that’s easy to locate and remember.
2627

2728
1. In the **Open Folder** dialog, select **Select Folder**.
2829

@@ -32,22 +33,32 @@ This module includes hands-on activities that guide you through the process of b
3233

3334
Notice that a command prompt in the Terminal panel displays the folder path for the current folder. For example:
3435

35-
```dos
36+
```PowerShell
3637
C:\Users\someuser\Desktop>
3738
```
3839
3940
> [!NOTE]
4041
> If you are working on your own PC rather than in a sandbox or hosted environment and you have completed other Microsoft Learn modules in this C# series, you may have already created a project folder for code samples. If that's the case, you can skip over the next step, which is used to create a console app in the TestProject folder.
4142
42-
1. At the Terminal command prompt, to create a new console application in a specified folder, type **dotnet new console -o ./CsharpProjects/TestProject** and then press Enter.
43+
1. At the Terminal command prompt, to create a new console application in a specified folder, enter the following prompt:
44+
45+
```dotnetcli
46+
dotnet new console -o ./CsharpProjects/TestProject
47+
```
48+
49+
This .NET CLI command uses a .NET program template to create a new C# console application project in the specified folder location. The command creates the CsharpProjects and TestProject folders for you, and uses TestProject as the name of your `.csproj` file.
4350
44-
This .NET CLI command uses a .NET program template to create a new C# console application project in the specified folder location. The command creates the CsharpProjects and TestProject folders for us, and uses TestProject as the name of our `.csproj` file.
51+
If a message is displayed telling you that the files already exist, continue with the next steps. You'll reuse the existing project files.
4552
46-
1. In the EXPLORER panel, expand the **CsharpProjects** folder.
53+
1. In the EXPLORER view, expand the **CsharpProjects** folder.
54+
55+
You should see the **TestProject** folder and two files, a C# program file named Program.cs and a C# project file named TestProject.csproj.
56+
57+
1. On the Visual Studio Code **File** menu, select **Open Folder**.
4758
48-
You should see the TestProject folder and two files, a C# program file named Program.cs and a C# project file named TestProject.csproj.
59+
1. In the **Open Folder** dialog, select the **CsharpProjects** folder, and then select **Select Folder**.
4960
50-
1. In the EXPLORER panel, to view your code file in the Editor panel, select **Program.cs**.
61+
1. In the EXPLORER view, expand the TestProject folder, and then select **Program.cs**.
5162
5263
1. Delete the existing code lines.
5364
@@ -238,7 +249,7 @@ What if we need to exit the iteration statement prematurely based on some condit
238249
239250
### Loop through each element of an array
240251
241-
A common usage for the `for` statement is to iterate through an array of elements, especially if you need some control over the manner in which the iteration happens. While the `foreach` iterates through every element of the array, the `for` statement can be tweaked to provide more customization.
252+
A common usage for the `for` statement is to iterate through an array of elements, especially if you need some control over the manner in which the iteration happens. While the `foreach` iterates through every element of the array, the `for` statement can be tweaked to provide more customizations.
242253
243254
1. Use the Visual Studio Code Editor to update your code as follows:
244255

learn-pr/wwl-language/csharp-for/includes/3-challenge.md renamed to learn-pr/wwl-language/csharp-for/includes/3-exercise-challenge-for-statements.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Code challenges will reinforce what you've learned and help you gain some confidence before continuing on.
1+
Code challenges reinforce what you've learned and help you gain some confidence before continuing on.
22

33
## FizzBuzz challenge
44

@@ -28,7 +28,7 @@ Here are the FizzBuzz rules that you need to implement in your code project:
2828
1. Write the code that implements each rule.
2929

3030
> [!IMPORTANT]
31-
> You will need to understand how to use the `%` remainder operator to determine if a number is divisible by another number evenly. We covered this in the module "Perform basic operations on numbers in C#".
31+
> You need to understand how to use the `%` remainder operator to determine if a number is divisible by another number evenly. We covered this in the module "Perform basic operations on numbers in C#".
3232
3333
1. Run your application and verify that your output meets the requirements.
3434

learn-pr/wwl-language/csharp-for/includes/4-solution.md renamed to learn-pr/wwl-language/csharp-for/includes/4-review-solution-for-statements-challenge.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ The code should produce the following output from 1 to 100.
132132
If you were successful, congratulations! Continue on to the knowledge check in the next unit.
133133

134134
> [!IMPORTANT]
135-
> If you had trouble completing this challenge, maybe you should review the previous units before you continue on. All new ideas we discuss in other modules will depend on your understanding of the ideas that were presented in this module.
135+
> If you had trouble completing this challenge, maybe you should review the previous units before you continue on. All new ideas we discuss in other modules depend on your understanding of the ideas that were presented in this module.

0 commit comments

Comments
 (0)