0% found this document useful (0 votes)
80 views8 pages

Generic Collections DotNetCore

The document explains generics in .NET Core, highlighting their benefits such as type safety, code reusability, and performance improvements. It outlines common generic collections like List<T>, Dictionary<TKey, TValue>, Queue<T>, Stack<T>, and HashSet<T>, along with examples of their usage. Additionally, it provides guidance on when to use each collection type based on specific use cases.

Uploaded by

kv.kavya96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views8 pages

Generic Collections DotNetCore

The document explains generics in .NET Core, highlighting their benefits such as type safety, code reusability, and performance improvements. It outlines common generic collections like List<T>, Dictionary<TKey, TValue>, Queue<T>, Stack<T>, and HashSet<T>, along with examples of their usage. Additionally, it provides guidance on when to use each collection type based on specific use cases.

Uploaded by

kv.kavya96
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Generic Collections in .

NET Core

Beginner to Intermediate Level


What are Generics?
• • Generics allow you to define type-safe data
structures.
• • Provide better performance and code
reusability.
• • Syntax: List<int> numbers = new List<int>();
Benefits of Generics
• • Type Safety
• • Code Reusability
• • Performance Improvements
• • Reduced Boxing/Unboxing
Common Generic Collections
in .NET Core
• • List<T>
• • Dictionary<TKey, TValue>
• • Queue<T>
• • Stack<T>
• • HashSet<T>
Examples: List and Dictionary
• List<string> names = new List<string>();
• [Link]("Alice");

• Dictionary<int, string> students = new


Dictionary<int, string>();
• [Link](1, "John");
Examples: Queue and Stack
• Queue<string> queue = new Queue<string>();
• [Link]("First");

• Stack<string> stack = new Stack<string>();


• [Link]("Top");
When to Use Which Collection?
• • Use List<T> for ordered, index-based access.
• • Use Dictionary<TKey, TValue> for key-value
pairs.
• • Use Queue<T> for FIFO operations.
• • Use Stack<T> for LIFO operations.
• • Use HashSet<T> for unique elements.
Summary
• • Generic Collections provide type safety and
flexibility.
• • Choose the right collection based on your
use case.
• • Practice with examples to understand
behavior.

• Questions?

You might also like