modify dictionary value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Slaughter

    modify dictionary value

    How do I modify the value of a dictionary object?

    I have something like

    Dictionary<stri ng, AQ = ...

    Where A is a struct.

    I want to change some values in A but

    Q["somestr"].x = 1;

    doesn't work because it makes them read only.

    If I do something like

    A a = Q["somestr"];

    a.x = 1;

    then of course it doesn't update the value in the dictionary.

    The only way I know to do it is remove the key and then re-add it with the
    new value... but surely there is a better way?


Working...