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-call-methods/includes/2-dotnet-class-library.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
2
+
3
+
1
4
There's more to building a C# application than stringing together lines of code. You'll need the .NET Runtime, which hosts and manages your code as it executes on the end user's computer. You'll also rely on the .NET Class Library, a prewritten collection of coding resources that you can use in your applications. This unit explains what the .NET Class Library is and how it complements the C# programming language.
Copy file name to clipboardExpand all lines: learn-pr/wwl-language/csharp-call-methods/includes/3-exercise-call-methods-dotnet-class.md
+26-11Lines changed: 26 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
2
+
3
+
1
4
Whether you realized it or not, you've been calling C# methods ever since your first "Hello, World!" application. That application uses the `WriteLine()` method of the `Console` class to display the "Hello, World!" message.
2
5
3
6
However, not all classes and methods are implemented the same way. This unit covers some of the most common variants that you'll need to understand when using methods from the .NET Class Library. More importantly, you'll learn how to find and use the documentation to better understand more about each method.
@@ -31,7 +34,7 @@ This module includes coding activities that guide you through the process of bui
31
34
32
35
1. On the Visual Studio Code **File** menu, select **Open Folder**.
33
36
34
-
1. In the **Open Folder** dialog, navigate to the **Windows Desktop** folder.
37
+
1. In the **Open Folder** dialog, navigate to the Windows Desktop folder.
35
38
36
39
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.
37
40
@@ -43,22 +46,32 @@ This module includes coding activities that guide you through the process of bui
43
46
44
47
Notice that a command prompt in the Terminal panel displays the folder path for the current folder. For example:
45
48
46
-
```dos
49
+
```PowerShell
47
50
C:\Users\someuser\Desktop>
48
51
```
49
52
50
53
> [!NOTE]
51
-
> 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 past the next step, which is used to create a console app in the TestProject folder.
54
+
> 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.
52
55
53
-
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.
56
+
1. At the Terminal command prompt, to create a new console application in a specified folder, enter the following prompt:
57
+
58
+
```dotnetcli
59
+
dotnet new console -o ./CsharpProjects/TestProject
60
+
```
54
61
55
62
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.
56
63
57
-
1. In the EXPLORER panel, expand the **CsharpProjects** folder.
64
+
If a message is displayed telling you that the files already exist, continue with the next steps. You'll reuse the existing project files.
58
65
59
-
You should see the TestProject folder and two files, a C# program file named Program.cs and a C# project file named TestProject.csproj.
66
+
1. In the EXPLORER view, expand the **CsharpProjects** folder.
60
67
61
-
1. In the EXPLORER panel, to view your code file in the Editor panel, select **Program.cs**.
68
+
You should see the **TestProject** folder and two files, a C# program file named Program.cs and a C# project file named TestProject.csproj.
69
+
70
+
1. On the Visual Studio Code **File** menu, select **Open Folder**.
71
+
72
+
1. In the **Open Folder** dialog, select the **CsharpProjects** folder, and then select **Select Folder**.
73
+
74
+
1. In the EXPLORER view, expand the TestProject folder, and then select **Program.cs**.
62
75
63
76
1. Delete the existing code lines.
64
77
@@ -84,17 +97,19 @@ This module includes coding activities that guide you through the process of bui
84
97
85
98
1. On the Visual Studio Code **File** menu, click **Save**.
86
99
87
-
1. In the EXPLORER panel, to open a Terminal at your TestProject folder location, right-click **TestProject**, and then select **Open in Integrated Terminal**.
100
+
1. In the EXPLORER view, to open a Terminal at your TestProject folder location, right-click **TestProject**, and then select **Open in Integrated Terminal**.
88
101
89
102
Notice that the Terminal panel includes a command prompt that displays a folder path. For example:
When you use the Terminal to run .NET CLI commands, this folder location is where the commands run. Ensure that your code folder matches the folder path displayed in the command prompt before you build or run your code.
108
+
When you use the Terminal to run .NET CLI commands, commands run from the displayed folder location. Ensure that your code folder matches the folder path displayed in the command prompt before you build or run your code.
94
109
95
110
1. At the Terminal command prompt, to run your code, type **dotnet run** and then press Enter.
96
111
97
-
Notice that a number from 1 to 6 is displayed in the console output (the number of dots on the dice). If you run the code enough times, you will eventually see each of the numbers displayed.
112
+
Notice that a number from 1 to 6 is displayed in the console output (the number of dots on the dice). If you run the code enough times, you'll see each of the numbers 1-6 displayed.
98
113
99
114
1. Take a minute to examine the syntax used to access the `Next()` and `WriteLine()` methods.
0 commit comments