Easy and simple (but not very nice) way is just to get the array of the keys and iterate it updating every string.
string[] mapKeys = myDictionary.Keys.ToArray();
for (int i = 0; i < mapKeys.Length; i++)
mapKeys [i] = mapKeys [i].Replace("substringToRemove", "");
But is there any way to do it in 1 line of code (e.g. using LINQ)?
mapKeys = mapKeys.Select(o=>o.Replace("substringToRemove", string.Empty)).ToArray();
or from your myDictionary:
string[] mapKeys = myDictionary.Keys.Select(o=>o.Replace("substringToRemove", string.Empty)).ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With