Filtering Products with a WHERE Clause in C#
📖 Scenario: You work at a small store that sells products. You have a list of products with their prices. You want to find only the products that cost less than $20 to decide what to put on sale.
🎯 Goal: Build a simple C# program that stores product names and prices, then uses a WHERE clause to filter and show only products cheaper than $20.
📋 What You'll Learn
Create a dictionary called
products with these exact entries: "Pen": 5, "Notebook": 15, "Backpack": 45, "Pencil": 3, "Eraser": 2Create an integer variable called
priceLimit and set it to 20Use a LINQ
Where clause with priceLimit to filter products for items with price less than priceLimitPrint the filtered products in the format
"Product: Price"💡 Why This Matters
🌍 Real World
Filtering products by price is common in stores to create sales or promotions.
💼 Career
Understanding how to filter data with WHERE clauses is essential for database queries and data processing in many programming jobs.
Progress0 / 4 steps