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: docs/csharp/tour-of-csharp/tutorials/list-collection.md
+12-14Lines changed: 12 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,21 @@
1
1
---
2
-
title: Data collections - Introductory interactive tutorial
2
+
title: Data collections - Introductory tutorial
3
3
description: In this tutorial, you use your browser to learn about C# collections. You write C# code and see the results of compiling and running your code directly in the browser.
4
4
ms.date: 03/07/2025
5
5
---
6
6
# Learn to manage data collections using List\<T> in C\#
7
7
8
8
This introductory tutorial provides an introduction to the C# language and the basics of the class.
9
9
10
-
This tutorial teaches you C# interactively, using your browser to write C# code and see the results of compiling and running your 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.
10
+
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.
11
11
12
-
## A basic list example
12
+
<< TODO Create the app>>
13
13
14
-
> [!TIP]
15
-
>
16
-
> When a code snippet block includes the "Run" button, that button opens the interactive window, or replaces the existing code in the interactive window. When the snippet doesn't include a "Run" button, you can copy the code and add it to the current interactive window.
14
+
## A basic list example
17
15
18
-
Run the following code in the interactive window. Replace `<name>` with your name and select **Run**:
16
+
Add the following code to your source file. Replace `<name>` with your name. Then, type `dotnet run` to run the code:
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.
23
21
@@ -43,7 +41,7 @@ You're not allowed to access past the end of the list. You can check how long th
Select **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.
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.
47
45
48
46
For more information about indices, see the [Explore indexes and ranges](../../tutorials/ranges-indexes.md) article.
49
47
@@ -61,15 +59,15 @@ The items in your list can be sorted as well. The <xref:System.Collections.Gener
61
59
62
60
## Lists of other types
63
61
64
-
You've been using the `string` type in lists so far. Let's make a <xref:System.Collections.Generic.List%601> using a different type. Let's build a set of numbers. Delete the code you wrote so far, and replace it with the following code:
62
+
You've been using the `string` type in lists so far. Let's make a <xref:System.Collections.Generic.List%601> using a different type. Let's build a set of numbers. Add the following code at the end of your source file:
That creates a list of integers, and sets the first two integers to the value 1. The *Fibonacci Sequence*, a sequence of numbers, starts with two 1's. Each next Fibonacci number is found by taking the sum of the previous two numbers. Add this code:
With each iteration of the loop, you're taking the last two integers in the list, summing them, and adding that value to the list. The loop repeats until you added 20 items to the list.
86
84
</details>
87
85
<!-- markdownlint-disable MD033 -->
88
86
89
-
You completed the list interactive tutorial, the final introduction to C# interactive tutorial. 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. Or, you can continue with the [Explore object oriented programming with classes and objects](../../fundamentals/tutorials/classes.md) tutorial.
87
+
You completed the list tutorial. You can continue with the [Pattern matching](./pattern-matching.md) tutorial.
90
88
91
89
You can learn more about [.NET collections](../../../standard/collections/index.md) in the following articles:
0 commit comments