This project provides beginner-friendly examples of the three most commonly used collection types in C#: arrays, lists, and dictionaries. Each collection type is demonstrated with practical code showing how to create, populate, iterate, and modify elements. The examples help illustrate when and why you might choose one collection over another.
The array example uses a fixed-size string array of days of the week, while the list example shows dynamic sizing with List<string> including add and modify operations. The dictionary example demonstrates Dictionary<int, string> for key-value pair storage. Each section includes iteration patterns using foreach loops, making this a useful reference for developers getting started with C# collections.
- .NET 7.0 SDK or later
cd ArraysListsDictionaries
dotnet run- Arrays, Lists, and Dictionaries in C# - When to Use Each Collection - Covers when and why to use arrays, lists, and dictionaries in C#
If you found this useful and you want to learn more about C#, .NET, and software engineering, subscribe to the free Dev Leader Weekly newsletter:
Subscribe to Dev Leader Weekly
- All Links
- Website - Dev Leader
- YouTube - Dev Leader
- YouTube - Dev Leader Path To Tech
- YouTube - Dev Leader Podcast
- YouTube - CodeCommute
- Newsletter - Dev Leader Weekly
- LinkedIn - Nick Cosentino
- GitHub - ncosentino
- Twitter/X - Dev Leader
- Threads - Dev Leader
- Bluesky - Dev Leader
- Mastodon - Dev Leader
- Facebook - Dev Leader
- TikTok - Dev Leader
- Twitch - Dev Leader
- Stack Overflow - Nick Cosentino
Powered by BrandGhost 👻