New course! Every coder should learn Generative AI!
Try a free lesson0
can we use "for each" loop in other programming languages also?
2 Answers
+ 2
Yes,we can use for each in other languages too like C#.Here is an example....
C# program that uses foreach over array using System;
class Program {
static void Main() {
string[] pets = { "dog", "cat", "bird" };
// ... Loop with the foreach keyword.
foreach (string value in pets) {
Console.WriteLine(value);
}
}
}
Output
dog
cat
bird
0
yes we use in Android, Java and C#.net