Delphi Error – E2431 for-in statement cannot operate on collection type ‘%s’ because ‘%s’ does not contain a member for ‘%s’, or it is inaccessible

Delphi Compiler Error

E2431 for-in statement cannot operate on collection type ‘%s’ because ‘%s’ does not contain a member for ‘%s’, or it is inaccessible

Reason for the Error & Solution

A for-in statement can only operate on the following collection types:

  • Primitive types that the compiler recognizes, such as arrays, sets or strings
  • Types that implement
  • Types that implement the GetEnumerator pattern as documented in the Delphi Language Guide

Ensure that the specified type meets these requirements.

See Also