Lists

Discover how lists provide a dynamic array-like data structure to store and manipulate a collection of elements of the same or different data types.

Introduction

Lists are a data structure in C# similar to arrays but with some added functionality. They are dynamic in size, which means that they can grow and shrink as needed, and they also offer several helpful methods for manipulating their contents. This lesson will explore the basics of lists in C#, how to use them, and some best practices for working with them.

Declaring and initializing lists

To create a list in C#, we first need to declare it and then initialize it with values. Here’s an example of how to do this:

Get hands-on with 1200+ tech skills courses.