J
Jon Slaughter
How do I modify the value of a dictionary object?
I have something like
Dictionary<string, A> Q = ...
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?
I have something like
Dictionary<string, A> Q = ...
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?