Dictionary methods and access patterns
📖 Scenario: You are managing a small store's inventory. You want to keep track of product names and their quantities using a dictionary.
🎯 Goal: Build a C# program that creates a dictionary of products and quantities, checks for a specific product, updates quantities, and prints the final inventory.
📋 What You'll Learn
Create a dictionary called
inventory with exact product names and quantitiesCreate a variable called
productToCheck with the exact value "Bananas"Use the
ContainsKey method to check if productToCheck is in inventoryIf the product exists, increase its quantity by 10 using the indexer
Print the final
inventory dictionary contents in the format Product: Quantity💡 Why This Matters
🌍 Real World
Managing store inventory is a common task where dictionaries help track product quantities efficiently.
💼 Career
Understanding dictionary methods and access patterns is essential for software developers working with data collections and real-world applications.
Progress0 / 4 steps