0

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?

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Mitja Bonca
0

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!
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.