🎴 Flashcard Mode
C# Programming
Card1 / 15
Mastered0
Review0
QuestionClick to flip
What will be the output of the following program?
using System; class Program
{
static void Main(string[] args)
{
String[] s = new String[2]; s[0] = Hello; s[1] = How are you!; foreach (string name: s)
{
Console.WriteLine( + name);
}
Console.ReadLine();
}
}
AnswerClick to flip back
A
It will not compile
💡 Explanation:
The code will not compile as there is an error in the syntax of foreach loop, there should be foreach (string name in s) instead of foreach (string name: s).