C# foreach loop

In this chapter you will learn:

  • What is foreach loop in C#?
  • How does it work?
  • How to use foreach loop in C# programming?

foreach loop is a different kind of looping constructs in C# programming that doesn’t includes initialization, termination and increment/decrement characteristics. It uses collection to take value one by one and then processes them.


Where, name is a string variable that takes value from collection as arr and then processes them in the body area.


Note: You will learn more about array in lateral chapter.


Hello Steven
Hello Clark
Hello Mark
Hello Thompson
Hello John


In this chapter you learned what foreach loop is and how to use it in C# programming. You also learned how to use foreach loop to access value from collection as array. In next chapter you will get some programming examples of loop constructs in C sharp.

Leave a Reply

Your email address will not be published. Required fields are marked *