Skip to content

Commit b9fe3ad

Browse files
committed
Edit for using codespaces
1 parent 947157c commit b9fe3ad

File tree

7 files changed

+90
-52
lines changed

7 files changed

+90
-52
lines changed

docs/csharp/tour-of-csharp/tutorials/branches-and-loops.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,29 @@ ms.date: 12/03/2025
77

88
This tutorial teaches you how to write C# code that examines variables and changes the execution path based on those variables. You write C# code and see the results of compiling and running it. The tutorial contains a series of lessons that explore branching and looping constructs in C#. These lessons teach you the fundamentals of the C# language.
99

10-
TODO: Build an app, create a file.
10+
To use codespaces, you need a GitHub account. If you don't already have one, you can create a free account at [GitHub.com](https://github.com).
1111

12-
Open *branches-loops.cs* in your favorite editor, and replace the contents with the following code:
12+
Open a browser window to [GitHub codespaces](https://github.com/codespaces). Create a new codespace from the *.NET Template*. If you've done other tutorials in this series, you can open that codespace. Once your codespace loads, create a new file in the *tutorials* folder named *branches-loops.cs*. Open your new file. Type or copy the following code into *branches-loops.cs*:
1313

1414
:::code language="csharp" source="./snippets/BranchesAndLoops/branches-loops.cs" id="FirstIf":::
1515

16-
Try this code by typing `dotnet run` in your console window. You should see the message "The answer is greater than 10." printed to your console. Modify the declaration of `b` so that the sum is less than 10:
16+
Try this code by typing the following in the integrated terminal:
17+
18+
```dotnetcli
19+
cd tutorials
20+
dotnet branches-loops.cs
21+
```
22+
23+
You should see the message "The answer is greater than 10." printed to your console. Modify the declaration of `b` so that the sum is less than 10:
1724

1825
```csharp
1926
int b = 3;
2027
```
2128

22-
Type `dotnet run` again. Because the answer is less than 10, nothing is printed. The **condition** you're testing is false. You don't have any code to execute because you've only written one of the possible branches for an `if` statement: the true branch.
29+
Type `dotnet branches-loops.cs` again in the terminal window. Because the answer is less than 10, nothing is printed. The **condition** you're testing is false. You don't have any code to execute because you've only written one of the possible branches for an `if` statement: the true branch.
2330

2431
> [!TIP]
25-
> As you explore C# (or any programming language), you'll make mistakes when you write code. The compiler will find and report the errors. Look closely at the error output and the code that generated the error. The compiler error can usually help you find the problem.
32+
> As you explore C# (or any programming language), you'll make mistakes when you write code. The compiler will find and report the errors. Look closely at the error output and the code that generated the error. You can also ask Copilot to find differences or spot any mistakes. The compiler error can usually help you find the problem.
2633
2734
This first sample shows the power of `if` and Boolean types. A *Boolean* is a variable that can have one of two values: `true` or `false`. C# defines a special type, `bool` for Boolean variables. The `if` statement checks the value of a `bool`. When the value is `true`, the statement following the `if` executes. Otherwise, it's skipped. This process of checking conditions and executing statements based on those conditions is powerful. Let's explore more.
2835

docs/csharp/tour-of-csharp/tutorials/hello-world.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,22 @@ ms.date: 12/02/2025
77

88
This tutorial teaches you C#. You write your first C# and see the results of compiling and running your code. It contains a series of lessons that begin with a "Hello World" program. These lessons teach you the fundamentals of the C# language.
99

10-
## Run your first program
10+
To use codespaces, you need a GitHub account. If you don't already have one, you can create a free account at [GitHub.com](https://github.com).
1111

12-
TODO: `dotnet new` or create a file.
12+
## Run your first program
1313

14-
Type the following code in your new `cs` file:
14+
Open a browser window to [GitHub codespaces](https://github.com/codespaces). Create a new codespace from the *.NET Template*. Once your codespace loads, create a new file in the *tutorials* folder named *hello-world.cs*. Open your new file. Type or copy the following code into *hello-world.cs*:
1515

1616
:::code language="csharp" source="./snippets/HelloWorld/hello-world.cs" id="HelloWorld":::
1717

18-
TODO: To run the program, type `dotnet run` (or) `dotnet file.cs` at the command prompt. Congratulations! You ran your first C# program. It's a simple program that prints the message "Hello World!" It used the <xref:System.Console.WriteLine%2A?displayProperty=nameWithType> method to print that message. `Console` is a type that represents the console window. `WriteLine` is a method of the `Console` type that prints a line of text to that text console.
18+
In the integrated terminal window, make the *tutorials* folder the current folder, and run your program:
19+
20+
```dotnetcli
21+
cd tutorials
22+
dotnet hello-world.cs
23+
```
24+
25+
Congratulations! You ran your first C# program. It's a simple program that prints the message "Hello World!" It used the <xref:System.Console.WriteLine%2A?displayProperty=nameWithType> method to print that message. `Console` is a type that represents the console window. `WriteLine` is a method of the `Console` type that prints a line of text to that text console.
1926

2027
Let's move on and explore more. The rest of this lesson explores working with the `string` type, which represents text in C#. Like the `Console` type, the `string` type has methods. The `string` methods work with text.
2128

@@ -25,7 +32,7 @@ Your first program printed the `string` "Hello World!" on the screen.
2532

2633
> [!TIP]
2734
>
28-
> As you explore C# (or any programming language), you make mistakes when you write code. The **compiler** finds those errors and report them to you. When the output contains error messages, look closely at the example code, and the code in your `.cs` file to see what to fix. That exercise helps you learn the structure of C# code.
35+
> As you explore C# (or any programming language), you make mistakes when you write code. The **compiler** finds those errors and report them to you. When the output contains error messages, look closely at the example code, and the code in your `.cs` file to see what to fix. That exercise helps you learn the structure of C# code. You can also ask Copilot to find differences or spot mistakes.
2936
3037
Your first program is limited to printing one message. You can write more useful programs by using *variables*. A *variable* is a symbol you can use to run the same code with different values. Let's try it! Start with the following code:
3138

@@ -46,7 +53,7 @@ You might notice that the word "Hello" was missing in the last two messages. Let
4653

4754
:::code language="csharp" source="./snippets/HelloWorld/hello-world.cs" id="ConcatMessage":::
4855

49-
TODO: Run the app again using `dotnet run` (or) `dotnet file.cs` to see the results.
56+
Run the app again using `dotnet hello-world.cs` to see the results.
5057

5158
You've been using `+` to build strings from **variables** and **constant** strings. There's a better way. You can place a variable between `{` and `}` characters to tell C# to replace that text with the value of the variable.
5259

@@ -56,7 +63,7 @@ If you add a `$` before the opening quote of the string, you can then include va
5663

5764
:::code language="csharp" source="./snippets/HelloWorld/hello-world.cs" id="Interpolation":::
5865

59-
TODO: Run the app again using `dotnet run` (or) `dotnet file.cs` to see the results. Instead of "Hello {aFriend}", the message should be "Hello Maira".
66+
Run the app again using `dotnet hello-world.cs` to see the results. Instead of "Hello {aFriend}", the message should be "Hello Maira".
6067

6168
## Work with strings
6269

@@ -124,7 +131,7 @@ Did you come up with something like the following (expand to see the answer):
124131
</details>
125132
<!-- markdownlint-enable MD033 -->
126133

127-
You completed the "Hello C#" introduction to C# tutorial. You can select the **Numbers in C#** tutorial to start the next tutorial, or you can visit the [.NET site](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro) to download the .NET SDK, create a project on your machine, and keep coding. The "Next steps" section brings you back to these tutorials.
134+
You completed the "Hello C#" introduction to C# tutorial. You can select the [Numbers in C#](./numbers-in-csharp.md) tutorial to start the next tutorial, or you can visit the [.NET site](https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro) to download the .NET SDK, create a project on your machine, and keep coding.
128135

129136
For further reading on the `string` type:
130137

docs/csharp/tour-of-csharp/tutorials/index.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
---
22
title: Interactive tutorials
33
description: Learn C# in your browser, and get started with your own development environment
4-
ms.date: 04/23/2025
4+
ms.date: 12/05/2025
55
---
66
# Introduction to C\#
77

8-
Welcome to the introduction to C# tutorials. These lessons start with interactive code that you can run in your browser. You can learn the basics of C# from the [C# for Beginners video series](https://aka.ms/dotnet/beginnervideos/youtube/csharp) before starting these interactive lessons.
8+
Welcome to the introduction to C# tutorials. These lessons start with interactive code that you can run in GitHub codespaces. You can learn the basics of C# from the [C# for Beginners video series](https://aka.ms/dotnet/beginnervideos/youtube/csharp) before starting these interactive lessons.
99

1010
<!--markdownlint-disable-next-line MD034 -->
1111
> [!VIDEO https://www.youtube.com/embed/9THmGiSPjBQ?si=3kUKFtOMLpEzeq7J]
1212
1313
The first lessons explain C# concepts using small snippets of code. You'll learn the basics of C# syntax and how to work with data types like strings, numbers, and booleans. It's all interactive, and you'll be writing and running code within minutes. These first lessons assume no prior knowledge of programming or the C# language. Each lesson builds on the prior lessons. You should do them in order. However, if you have some programming experience, you can skip or skim the first lessons and start with any new concepts.
1414

15-
You can try these tutorials in different environments. The concepts you'll learn are the same. The difference is which experience you prefer:
16-
17-
- [In your browser, on the docs platform](hello-world.md): This experience embeds a runnable C# code window in docs pages. You write and execute C# code in the browser.
18-
- [In the Microsoft Learn training experience](/training/paths/csharp-first-steps/). This learning path contains several modules that teach the basics of C#.
15+
To use GitHub codespaces, you need to create a free [GitHub](https://github.com) account.
1916

2017
## Hello world
2118

22-
In the [Hello world](hello-world.md) tutorial, you'll create the most basic C# program. You'll explore the `string` type and how to work with text. You can also use the path on [Microsoft Learn training](/training/paths/csharp-first-steps/).
19+
In the [Hello world](hello-world.md) tutorial, you'll create the most basic C# program. You'll explore the `string` type and how to work with text.
2320

2421
## Numbers in C\#
2522

docs/csharp/tour-of-csharp/tutorials/list-collection.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,25 @@ ms.date: 03/07/2025
55
---
66
# Learn to manage data collections using List\<T> in C\#
77

8-
This introductory tutorial provides an introduction to the C# language and the basics of the class.
8+
This introductory tutorial provides an introduction to the C# language and the basics of the <xref:System.Collections.Generic.List`1?displayProperty=nameWithType> class.
99

1010
This tutorial teaches you C#. You write C# code and see the results of compiling and running that code. It contains a series of lessons that create, modify, and explore collections and arrays. You work primarily with the <xref:System.Collections.Generic.List%601> class.
1111

12-
<< TODO Create the app>>
12+
To use codespaces, you need a GitHub account. If you don't already have one, you can create a free account at [GitHub.com](https://github.com).
1313

1414
## A basic list example
1515

16-
Add the following code to your source file. Replace `<name>` with your name. Then, type `dotnet run` to run the code:
16+
Open a browser window to [GitHub codespaces](https://github.com/codespaces). Create a new codespace from the *.NET Template*. If you've done other tutorials in this series, you can open that codespace. Once your codespace loads, create a new file in the *tutorials* folder named *lists.cs*. Open your new file. Type or copy the following code into *lists.cs*:
1717

1818
:::code language="csharp" source="./snippets/ListCollection/list.cs" id="BasicList":::
1919

20+
Run the code by typing the following in the terminal window:
21+
22+
```dotnetcli
23+
cd tutorials
24+
dotnet lists.cs
25+
```
26+
2027
You created a list of strings, added three names to that list, and printed the names in all CAPS. You're using concepts that you learned in earlier tutorials to loop through the list.
2128

2229
The code to display names makes use of the [string interpolation](../../language-reference/tokens/interpolated.md) feature. When you precede a `string` with the `$` character, you can embed C# code in the string declaration. The actual string replaces that C# code with the value it generates. In this example, it replaces the `{name.ToUpper()}` with each name, converted to capital letters, because you called the <xref:System.String.ToUpper%2A?displayProperty=nameWithType> method.
@@ -41,7 +48,7 @@ You're not allowed to access past the end of the list. You can check how long th
4148

4249
:::code language="csharp" source="./snippets/ListCollection/list.cs" id="Property":::
4350

44-
Type `dotnet run` again to see the results. In C#, indices start at 0, so the largest valid index is one less than the number of items in the list.
51+
Type `dotnet lists.cs` again in the terminal window to see the results. In C#, indices start at 0, so the largest valid index is one less than the number of items in the list.
4552

4653
For more information about indices, see the [Explore indexes and ranges](../../tutorials/ranges-indexes.md) article.
4754

@@ -67,7 +74,7 @@ That creates a list of integers, and sets the first two integers to the value 1.
6774

6875
:::code language="csharp" source="./snippets/ListCollection/list.cs" id="Fibonacci":::
6976

70-
Type `dotnet run` to see the results.
77+
Type `dotnet lists` in the terminal window to see the results.
7178

7279
## Challenge
7380

docs/csharp/tour-of-csharp/tutorials/numbers-in-csharp.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ ms.date: 12/02/2025
77

88
This tutorial teaches you about the numeric types in C#. You write small amounts of code, then you compile and run that code. The tutorial contains a series of lessons that explore numbers and math operations in C#. These lessons teach you the fundamentals of the C# language.
99

10-
## Explore integer math
11-
12-
Create a directory named *numbers-quickstart*. Make it the current directory and run the following command:
10+
To use codespaces, you need a GitHub account. If you don't already have one, you can create a free account at [GitHub.com](https://github.com).
1311

14-
```dotnetcli
15-
dotnet new console -n NumbersInCSharp -o .
16-
```
12+
## Explore integer math
1713

18-
Open *numbers.cs* in your favorite editor, and replace the contents of the file with the following code:
14+
Open a browser window to [GitHub codespaces](https://github.com/codespaces). Create a new codespace from the *.NET Template*. If you've done the [hello world](./hello-world.md) tutorial, you can open that codespace. Once your codespace loads, create a new file in the *tutorials* folder named *numbers.cs*. Open your new file. Type or copy the following code into *numbers.cs*:
1915

2016
:::code language="csharp" source="./snippets/NumbersInCsharp/numbers.cs" id="Addition":::
21-
Addition
2217

23-
Run this code by typing `dotnet run` in your command window.
18+
Run this code by typing the following commands in the integrated terminal:
19+
20+
```dotnetcli
21+
cd ./tutorials
22+
dotnet numbers.cs
23+
```
2424

2525
You've seen one of the fundamental math operations with integers. The `int` type represents an **integer**, a zero, positive, or negative whole number. You use the `+` symbol for addition. Other common mathematical operations for integers include:
2626

@@ -32,12 +32,12 @@ Start by exploring those different operations. Add these lines after the line th
3232

3333
:::code language="csharp" source="./snippets/NumbersInCsharp/numbers.cs" id="OtherOperations":::
3434

35-
Run this code by typing `dotnet run` in your command window.
35+
Run this code by typing `dotnet numers.cs` in the terminal window.
3636

3737
You can also experiment by writing multiple mathematics operations in the same line, if you'd like. Try `c = a + b - 12 * 17;` for example. Mixing variables and constant numbers is allowed.
3838

3939
> [!TIP]
40-
> As you explore C# (or any programming language), you'll make mistakes when you write code. The **compiler** will find those errors and report them to you. When the output contains error messages, look closely at the example code and the code in your window to see what to fix. That exercise will help you learn the structure of C# code.
40+
> As you explore C# (or any programming language), you'll make mistakes when you write code. The **compiler** will find those errors and report them to you. When the output contains error messages, look closely at the example code and the code in your window to see what to fix. You can also ask Copilot to find differences or spot mistakes. That exercise will help you learn the structure of C# code.
4141
4242
You've finished the first step. Before you start the next section, let's move the current code into a separate *method*. A method is a series of statements grouped together and given a name. You call a method by writing the method's name followed by `()`. Organizing your code into methods makes it easier to start working with a new example. When you finish, your code should look like this:
4343

@@ -76,7 +76,7 @@ Comment out the call to `WorkingWithIntegers()`. It will make the output less cl
7676

7777
The `//` starts a **comment** in C#. Comments are any text you want to keep in your source code but not execute as code. The compiler doesn't generate any executable code from comments. Because `WorkWithIntegers()` is a method, you need to only comment out one line.
7878

79-
The C# language defines the precedence of different mathematics operations with rules consistent with the rules you learned in mathematics. Multiplication and division take precedence over addition and subtraction. Explore that by adding the following code after the call to `WorkWithIntegers()`, and executing `dotnet run`:
79+
The C# language defines the precedence of different mathematics operations with rules consistent with the rules you learned in mathematics. Multiplication and division take precedence over addition and subtraction. Explore that by adding the following code after the call to `WorkWithIntegers()`, and typing `dotnet numbers.cs` in the terminal window:
8080

8181
:::code language="csharp" source="./snippets/NumbersInCsharp/numbers.cs" id="Precedence":::
8282

@@ -86,7 +86,7 @@ You can force a different order of operation by adding parentheses around the op
8686

8787
:::code language="csharp" source="./snippets/NumbersInCsharp/numbers.cs" id="Parentheses":::
8888

89-
Explore more by combining many different operations. Add something like the following lines. Try `dotnet run` again.
89+
Explore more by combining many different operations. Add something like the following lines. Try `dotnet numbers` again in the terminal window.
9090

9191
:::code language="csharp" source="./snippets/NumbersInCsharp/numbers.cs" id="CompoundExpression":::
9292

@@ -96,7 +96,7 @@ If you haven't seen this behavior, try the following code:
9696

9797
:::code language="csharp" source="./snippets/NumbersInCsharp/numbers.cs" id="Truncation":::
9898

99-
Type `dotnet run` again to see the results.
99+
Type `dotnet numbers` again in the terminal window to see the results.
100100

101101
Before moving on, let's take all the code you've written in this section and put it in a new method. Call that new method `OrderPrecedence`. Your code should look something like this:
102102

0 commit comments

Comments
 (0)