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/wwl-language/csharp-arrays-operations/includes/2-exercise-sort-reverse.md
+94-29Lines changed: 94 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,79 +8,144 @@ The `Array` class contains methods that you can use to manipulate the content, a
8
8
This module includes hands-on activities that guide you through the process of building and running demonstration code. You're encouraged to complete these activities using Visual Studio Code as your development environment. Using Visual Studio Code for these activities will help you to become more comfortable writing and running code in a developer environment that's used by professionals worldwide.
9
9
10
10
1. Open Visual Studio Code.
11
-
You can use the Windows Start menu (or equivalent resource for another OS) to open Visual Studio Code.
11
+
12
+
You can use the Windows Start menu (or equivalent resource for another OS) to open Visual Studio Code.
12
13
13
14
1. On the Visual Studio Code **File** menu, select **Open Folder**.
14
15
15
16
1. In the **Open Folder** dialog, navigate to the Windows Desktop folder.
16
-
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.
17
+
18
+
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.
17
19
18
20
1. In the **Open Folder** dialog, select **Select Folder**.
19
-
If you see a security dialog asking if you trust the authors, select **Yes**.
21
+
22
+
If you see a security dialog asking if you trust the authors, select **Yes**.
20
23
21
24
1. On the Visual Studio Code **Terminal** menu, select **New Terminal**.
22
-
Notice that a command prompt in the Terminal panel displays the folder path for the current folder. For example:
23
-
```dos C:\Users\someuser\Desktop> ```
24
-
> [!NOTE] > If 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.
25
+
26
+
Notice that a command prompt in the Terminal panel displays the folder path for the current folder. For example:
27
+
28
+
```dos
29
+
C:\Users\someuser\Desktop>
30
+
```
31
+
32
+
> [!NOTE]
33
+
> If 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.
25
34
26
35
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.
27
-
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 the `.csproj` file.
36
+
37
+
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 the `.csproj` file.
28
38
29
39
1. In the EXPLORER panel, expand the **CsharpProjects** folder.
30
-
You should see the TestProject folder and two files, a C# program file named Program.cs and a C# project file named TestProject.csproj.
40
+
41
+
You should see the TestProject folder and two files, a C# program file named Program.cs and a C# project file named TestProject.csproj.
31
42
32
43
1. In the EXPLORER panel, to view your code file in the Editor panel, select **Program.cs**.
33
44
34
45
1. Delete the existing code lines.
35
-
You'll be using this C# console project to create, build, and run code samples during this module.
46
+
47
+
You'll be using this C# console project to create, build, and run code samples during this module.
36
48
37
49
1. Close the Terminal panel.
38
50
39
51
### Create an array of pallets, then sort them
40
52
41
53
1. Ensure that you have Visual Studio Code open and Program.cs displayed in the Editor panel.
42
-
> [!NOTE] > Program.cs should be empty. If if isn't, select and delete all code lines.
54
+
55
+
> [!NOTE]
56
+
> Program.cs should be empty. If if isn't, select and delete all code lines.
43
57
44
58
1. Type the following code into the Visual Studio Code Editor:
1. Take a minute to review the `Array.Sort(pallets);` line from the previous code you added.
50
-
Here you're using the `Sort()` method of the `Array` class to sort the items in the array alphanumerically.
73
+
74
+
Here you're using the `Sort()` method of the `Array` class to sort the items in the array alphanumerically.
51
75
52
76
1. On the Visual Studio Code **File** menu, select **Save**.
53
-
The Program.cs file must be saved before building or running the code.
77
+
78
+
The Program.cs file must be saved before building or running the code.
54
79
55
80
1. In the EXPLORER panel, to open a Terminal at your TestProject folder location, right-click **TestProject**, and then select **Open in Integrated Terminal**.
56
-
A Terminal panel should open, and should include a command prompt showing that the Terminal is open to your TestProject folder location.
81
+
82
+
A Terminal panel should open, and should include a command prompt showing that the Terminal is open to your TestProject folder location.
57
83
58
84
1. At the Terminal command prompt, to run your code, type **dotnet run** and then press Enter.
59
-
> [!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>`
60
-
You should see the following output:
61
-
```Output Sorted... -- A11 -- A13 -- B12 -- B14
62
-
```
85
+
86
+
> [!NOTE]
87
+
> 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>`
88
+
89
+
You should see the following output:
90
+
91
+
```Output
92
+
Sorted...
93
+
-- A11
94
+
-- A13
95
+
-- B12
96
+
-- B14
97
+
98
+
```
63
99
64
100
### Reverse the order of the pallets
65
101
66
102
1. To reverse the order of the pallets using the `Array.Reverse()` method, update your code as follows:
0 commit comments