V
vcquestions
trying to design an effiecient interface, where I can pass an
IDictionary<int,string^> to a method. int is some id and string^ is
some
value that is initialized to null by a caller.
The callee function needs to update the value based on the key.
in native code I'd have passed a std::map and do ((*it).second) = new
std::string("test");
I don't see a way to do it in managed code.
I obviously can't assign it to keyValuePair element as it's read only.
And I can't even do this:
for each ( KeyValuePair<int, string^>^ iter in testCollection )
{
testCollection[iter->key] = "test"
}
as on the second pass of the loop, the code above will throw since the
colleciton is modified.
Thus, it looks like I need 2 passes, where I'd make a list of ids in
the first pass and on the second pass, I'd do something
like:
for ( int i = 0; i < ListIds.Count; ++i )
{
testCollection[listIds] = "test";
}
This code seems very poor. Is there really no way to update the
IDictionary<key,value> in 1 pass? I've got to be missing some
IEnumerator that would let me do that
Thanks in advance!
vcq
IDictionary<int,string^> to a method. int is some id and string^ is
some
value that is initialized to null by a caller.
The callee function needs to update the value based on the key.
in native code I'd have passed a std::map and do ((*it).second) = new
std::string("test");
I don't see a way to do it in managed code.
I obviously can't assign it to keyValuePair element as it's read only.
And I can't even do this:
for each ( KeyValuePair<int, string^>^ iter in testCollection )
{
testCollection[iter->key] = "test"
}
as on the second pass of the loop, the code above will throw since the
colleciton is modified.
Thus, it looks like I need 2 passes, where I'd make a list of ids in
the first pass and on the second pass, I'd do something
like:
for ( int i = 0; i < ListIds.Count; ++i )
{
testCollection[listIds] = "test";
}
This code seems very poor. Is there really no way to update the
IDictionary<key,value> in 1 pass? I've got to be missing some
IEnumerator that would let me do that
Thanks in advance!
vcq