foreach dictionary code example
Example 1: how to do a foreach loop in c# for dictionary
foreach (KeyValuePair<string, int> kvp in myDictionary)
{
print(kvp)
}
Example 2: foreach key value javascript
const object1 = {
a: 'somestring',
b: 42
};
for (let [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
// expected output:
// "a: somestring"
// "b: 42"
// order is not guaranteed
Example 3: foreach dictionary c#
foreach(KeyValuePair<string, string> entry in myDictionary)
{
// do something with entry.Value or entry.Key
}