for-in loop

Top  Previous  Next

What is translated > Statements > for loop's > for-in loop

 

 

for-in loops are a special kind of Delphi for-loops which have the syntax:

 

 

var

  a : typename;

begin

for a in B do

  DoSomething(a);

 

 

where 'a' may be a character in a string 'B' or  'a' may be an element of an array 'B' or  'a' may be a member of a set 'B'. All these cases are translated to a C# for_each statements:

 

typename a;

 

foreach (typename element_0 : B)

{

  a = element_0;

  DoSomething(a);

}

    

 

 

 



This page belongs to the Delphi2C# Documentation

Delphi2C# home  Content