C# — Collections
List
List<int> nums = new List<int> { 1, 2, 3 };
nums.Add(4);
Dictionary
Dictionary<string, int> ages = new();
ages["Alice"] = 25;
Queue/Stack
Queue<string> queue = new();
queue.Enqueue("first");
Stack<string> stack = new();
stack.Push("first");
Mini Practice
- Use List
- Use Dictionary
- Practice Queue/Stack
- Iterate collections
Up Next
Continue with Reflection - Runtime inspection.
Related Topics
Frequently Asked Questions about Collections
What is Collections in C#?
Collections is a fundamental concept in C#. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Collections?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Collections.
Why is Collections important in C#?
Collections is essential for C# development. Understanding this concept will help you write better code and solve real-world problems more effectively.