Common Bugs from Reference Sharing in C#
📖 Scenario: Imagine you are working on a simple inventory system for a small store. You have a list of products, and you want to create a copy of this list to apply discounts without changing the original list.This project will help you understand how sharing references between objects can cause unexpected bugs.
🎯 Goal: You will create a list of products, then create a copy of this list. You will apply a discount to the copied list and observe how changes affect the original list due to reference sharing.
📋 What You'll Learn
Create a list of products with exact names and prices
Create a copy of the product list by assigning it to a new variable
Apply a discount to the copied list by changing product prices
Print both original and copied lists to observe the effect of reference sharing
💡 Why This Matters
🌍 Real World
Understanding reference sharing helps prevent bugs in programs that manage collections of objects, like inventory systems, user lists, or game entities.
💼 Career
Many programming jobs require managing data structures carefully to avoid unintended side effects from shared references, especially in object-oriented languages like C#.
Progress0 / 4 steps