Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed C# Objects!
You have completed C# Objects!
Preview
Foreach loops are special loops intended for collections (like arrays).
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
It turns out that looping through all the
items of a collection such as an array is
0:00
so common that there is yet another type
of loop that's designed to do just that.
0:03
It's called a for each loop.
0:09
I'll write what that looks like
below our existing four a loop, so
0:12
that we can compare the two loops.
0:15
With the four each loop we get rid of
the loop counter variable entirely.
0:21
This loop will always run if there's
at least one item in the array.
0:26
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up