Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Can one replace a value in a Directory(Of TKey, TValue)?

$
0
0

I want to replace the value for a particular key in a Directory(Of TKey, TValue) when I know that the key already exists.

It's in a loop of the type:

for each KVP in Directory
  if NeedsChanging(KVP.Value)
    Directory(KVP.Key)=NewValue
  end if
next

But I get an error as this also potentially updates the key and destroys the loop. Is there any way round this, apart from batching up the  replacements in a list during the loop and updating the directory entries in a separate loop?

Or is there a Replace(TKey, TValue) method for Directory which I've not managed to find?



Peter


Viewing all articles
Browse latest Browse all 8156

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>