I dont understand how this works
string[] friends = { "Zuka", "Jajo", "Bedo", "Quji", "Rhaast" };
Console.WriteLine(" ");
foreach (string s in friends)
{
Console.WriteLine("Hello " + s);
}
so why does the string s transform into the friends I understood for how it worked with ints but I dont get it for strings
3 Replies
The loop gets each string from the
friends
array
And saves it in variable s
So with first iteration, s
is "Zuka"
. With the second iteration, s
is "Jajo"
, and so onohhh
so every variable in the friends array is = to s
okay ty very much for the help and calirification
Anytime