Hi. Let's say I have a method in a foreach statement, for example:

foreach(string str in GetStrings())

Does the method (GetStrings() in our example) get called once or once per iteration?


It gets called just once.


Only ones of course.
Different would be something like that:

string[] array = GetString();
//method GetString returns an array of strings
//you you go through a foreach loop like it:
foreach(string str in array)
   here you can loop through str string!