how to use foreach loop in c sharp application

How to use foreach loop

today i will teach you how to use for each loop in c sharp application before you use for each  …For each loop  use for execute multiple statement  in one time…Syntax of for each loop ..foreach(data type var-name in expression ){
  block of statements}Example Suppose you crate a array which name is a and it range is 4 .you  want to print all the value in array you don’t want to write  multiple  statement to print value of array. so you have better option to print all value of array you use foreach loop


Ans..int[]a=new int[4]{10,20,30,40};

foreach(int x in a)

{

Console.WriteLine(x);

}

spot_img

Related Articles

Indian state wise cultural dance

आजकल प्रतियोगी परीक्षायों में हमारे देश के विभिन्न विभिन्न नृत्य के बारे में पूछा जाता है हमारे देश के प्रमुख...
Read more
MCQ ON INDIAN ECONOMY
1. Why are coal companies moving towards outsourcing mode?A) To increase employment opportunitiesB) To reduce costs and become more competitiveC)...