C# dictionary value clearing out when I clear list previously assigned to it....why?
c#, dictionary
Solution
The dictionary contains the same reference to the list, so modifying the list will change both references.
Microsoft documentation about reference types: http://msdn.microsoft.com/en-us/library/490f96s2.aspx
Problem
``` Dictionary <string, List <SaleItem>> saleItemNew = new Dictionary<string, List< SaleItem>> (); saleItems = new List <SaleItem> (); saleItemNew.Add("1", saleItems); ``` At this point the list in the Dictionary has values. ``` saleItems.Clear(); ``` However, when I clear out the list previously assigned to it, the dictionary's value List is now empty...why?