Skip to content

Commit 0a28da7

Browse files
authored
pull base content,head:MicrosoftDocs:main,into:wwlpublishsync
2 parents 9ae021f + e5ee9bf commit 0a28da7

18 files changed

+625
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: "Introduction to the module."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 2
14+
content: |
15+
[!include[](includes/1-introduction.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.importance-collections
3+
title: Importance of collections
4+
metadata:
5+
title: Importance of collections
6+
description: "Learn about the significance of collections in C# for managing groups of objects efficiently."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 5
14+
content: |
15+
[!include[](includes/2-importance-collections.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.implement-ordered-collections-typed-list
3+
title: Implement ordered collections with List<T>
4+
metadata:
5+
title: Implement ordered collections with List<T>
6+
description: "Learn how to use List for managing ordered collections, including adding, removing, and iterating through items."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 6
14+
content: |
15+
[!include[](includes/3-implement-ordered-collections-typed-list.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.ensure-uniqueness-typed-hashset
3+
title: Ensuring uniqueness with HashSet<T>
4+
metadata:
5+
title: Ensuring uniqueness with HashSet<T>
6+
description: "Explore how to use HashSet to manage unique collections and prevent duplicate elements."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 6
14+
content: |
15+
[!include[](includes/4-ensure-uniqueness-typed-hashset.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.organize-data-key-value-pairs-use-typed-dictionary
3+
title: Organize data with Dictionary<TKey, TValue>
4+
metadata:
5+
title: Organize data with Dictionary<TKey, TValue>
6+
description: "Learn how to use Dictionary for storing and retrieving data using key-value pairs efficiently."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 8
14+
content: |
15+
[!include[](includes/5-organize-data-key-value-pairs-use-typed-dictionary.md)]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.exercise-implement-collection-types
3+
title: Exercise - Implement collection types
4+
metadata:
5+
title: Exercise - Implement collection types
6+
description: "Practice implementing and using collection types like List, Dictionary, and HashSet in a banking application scenario."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 30
14+
content: |
15+
[!include[](includes/6-exercise-implement-collection-types.md)]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.knowledge-check
3+
title: Knowledge check
4+
metadata:
5+
title: Knowledge check
6+
description: "Check what you've learned in this module."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 3
14+
content: |
15+
[!include[](includes/7-knowledge-check.md)]
16+
quiz:
17+
title: "Check your knowledge"
18+
questions:
19+
- content: "What is the primary characteristic of a `HashSet<T>` in C#?"
20+
choices:
21+
- content: "It allows duplicate elements."
22+
isCorrect: false
23+
explanation: "Incorrect. `HashSet<T>` doesn't allow duplicate elements, making it ideal for scenarios requiring uniqueness."
24+
- content: "It stores elements as key/value pairs."
25+
isCorrect: false
26+
explanation: "Incorrect. Storing elements as key/value pairs is a characteristic of `Dictionary<TKey, TValue>`, not `HashSet<T>`."
27+
- content: "It ensures uniqueness of elements."
28+
isCorrect: true
29+
explanation: "Correct. `HashSet<T>` is designed to ensure that all elements are unique, which is its primary characteristic."
30+
- content: "A banking application needs to store customer IDs with their associated account details for quick retrieval. Which collection should be used?"
31+
choices:
32+
- content: "`List<Account>`"
33+
isCorrect: false
34+
explanation: "Incorrect. `List<Account>` is suitable for ordered records but doesn't provide quick look-up by customer ID."
35+
- content: "`Dictionary<int, Account>`"
36+
isCorrect: true
37+
explanation: "Correct. `Dictionary<int, Account>` is ideal for associating customer IDs with account details, enabling efficient look-up by key."
38+
- content: "`HashSet<Account>`"
39+
isCorrect: false
40+
explanation: "Incorrect. `HashSet<Account>` ensures uniqueness but doesn't support key-based look-up, which is required in this scenario."
41+
- content: "Which of these collections in C# supports dynamic resizing and access to elements by index?"
42+
choices:
43+
- content: "`List<T>`"
44+
isCorrect: true
45+
explanation: "Correct. `List<T>` supports dynamic resizing and allows access to elements by their index, making it versatile for various scenarios."
46+
- content: "`Dictionary<TKey, TValue>`"
47+
isCorrect: false
48+
explanation: "Incorrect. `Dictionary<TKey, TValue>` stores elements as key/value pairs and doesn't provide index-based access."
49+
- content: "`HashSet<T>`"
50+
isCorrect: false
51+
explanation: "Incorrect. `HashSet<T>` is designed for set operations and doesn't support index-based access or dynamic resizing."
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.implement-collection-types.summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: "Summarize the key concepts covered in this module."
7+
ms.date: 03/28/2025
8+
author: wwlpublish
9+
ms.author: eric
10+
ms.topic: unit
11+
ms.custom:
12+
- N/A
13+
durationInMinutes: 2
14+
content: |
15+
[!include[](includes/8-summary.md)]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
C# collections are powerful tools for managing groups of objects dynamically, ensuring type safety and efficient data manipulation for various applications.
2+
3+
Imagine you're working in the banking industry, tasked with developing a system that manages customer accounts and transactions. You need a way to store customer IDs linked to their account details, ensure no duplicate transaction records, and maintain an ordered list of recent activities. Without the right tools, this task could become cumbersome and error-prone. C# collections like `List<T>`, `HashSet<T>`, and `Dictionary<TKey, TValue>` offer solutions tailored to these challenges. For instance, you can use `Dictionary<TKey, TValue>` to map customer IDs to account details for quick lookups, `HashSet<T>` to ensure transaction uniqueness, and `List<T>` to maintain an ordered sequence of activities. These collections streamline data management, making your application robust and efficient.
4+
5+
## Learning objectives
6+
7+
- Apply C# Collections for Efficient Data Management
8+
- Manage ordered collections using `List<T>` in C#
9+
- Manage unique collections with `HashSet<T>`
10+
- Using `Dictionary<TKey, TValue>` for efficient key-value pair management in C#
11+
12+
## Prerequisites
13+
14+
- Visual Studio Code installed with the C# Dev Kit.
15+
- Basic knowledge of the Visual Studio Code IDE.
16+
- Basic understanding of the C# programming language.
17+
- Familiar with classes, abstract classes, interfaces and inheritance.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
In C#, collections are essential for managing groups of objects efficiently. They provide a flexible way to store, retrieve, and manipulate data, which is crucial for developers working on various applications, including applications in the banking sector.
2+
3+
## Importance of collections in managing groups of objects
4+
5+
Collections in C# allow developers to handle similar data more efficiently by storing and manipulating it as a group. This capability is vital for applications that require dynamic data handling, such as adding or removing elements. Collections can be classified based on how they access elements, their performance profiles, and their ability to grow or shrink dynamically. For instance, some collections access elements by index, like `List<T>`, while others use keys, like `Dictionary<TKey, TValue>`.
6+
7+
- Collections are strongly typed, meaning they store elements of a specific type (`T`), ensuring type safety and reducing runtime errors.
8+
- Collections provide methods for adding, removing, or finding items.
9+
- They support enumeration, allowing iteration over elements using loops.
10+
- Collections can be copied to arrays, providing flexibility in data manipulation.
11+
12+
> [!NOTE]
13+
> For examples, you might need to add using directives for the `System.Collections.Generic` and `System.Linq` namespaces.
14+
15+
## Describe List&#60;T&#62;, HashSet&#60;T&#62;, and Dictionary&#60;TKey, TValue&#62;
16+
17+
### **List&#60;T&#62;**
18+
19+
`List<T>` is an indexable collection that allows access to elements by their position. It supports dynamic resizing, making it suitable for scenarios where the number of elements can change.
20+
21+
### **HashSet&#60;T&#62;**
22+
23+
`HashSet<T>` is a collection designed for high-performance set operations. It doesn't allow duplicate elements and is ideal for scenarios where uniqueness is required.
24+
25+
### **Dictionary&#60;TKey, TValue&#62;**
26+
27+
`Dictionary<TKey, TValue>` stores elements as key/value pairs, enabling quick look-up by key. It's useful when you need to associate values with unique keys, such as mapping customer IDs to account details in a banking application.
28+
29+
## Prepare for application of collections in banking scenarios
30+
31+
In banking applications, collections play a crucial role in managing data efficiently. For example, a `Dictionary<int, Account>` can map customer IDs to their respective account details, allowing quick retrieval and updates. Similarly, a `List<Transaction>` can store a sequence of transactions, supporting operations like sorting and filtering using LINQ (Language Integrated Query).
32+
33+
- Use `Dictionary<TKey, TValue>` for quick look-up of customer data.
34+
- Employ `List<T>` for ordered transaction records.
35+
- Utilize `HashSet<T>` to ensure unique entries, such as customer IDs.
36+
37+
With collections, developers can build robust and efficient banking applications that handle data dynamically and securely.

0 commit comments

Comments
 (0)