Feedback
For Each over Dictionary.Keys can report Array as the element type
- Status
- Fixed
- Fixed in
- v26.6.3
- Source discussion
- https://forum.objo.dev/d/325-error-when-iterating-dictionary-over-keys
- Last updated
- 2026-06-11
Public summary
Iterating over the Keys property from an untyped Dictionary with a typed For Each loop variable can produce a misleading compiler error: For Each variable type 'String' does not match collection element type 'Array'. The bundled dictionary docs also show key-iteration examples without making clear that For Each key As String In dict.Keys requires a parameterised dictionary such as Dictionary(Of String, ...), making the example easy to copy into code that uses an untyped dictionary.