Tech Off Post

Single Post Permalink

View Thread: How To Modify An Element in the Dictionary Class?
  • User profile image
    felix9

    Note, you should be really carefull about value types here, for example, this code get it wrong:

                var dict = new Dictionary<int, System.Windows.Point>();
                dict[1] = new System.Windows.Point(10, 10);
                Console.WriteLine(dict[1].ToString()); // outputs 10,10
                dict[1].Offset(10, 10); // modifying a COPY, the one in the dictionary is not changed
                Console.WriteLine(dict[1].ToString()); // still outputs 10,10