Hi,
What is the main use of foreach in C# . Instead of using simple for loop. Is all .Net frame work support foreach.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 9, 2014, 2:31 AM EDT
This includes arrays and lists amongst other collections.
However, it can't be used to add or remove elements to or from the collection. You need to use an ordinary 'for' loop for this.