Q170
What will be the output of the following C# code snippet? class MyClass char[] chrs = 'A', 'B', 'C', 'D' ; public System.Collections.IEnumerator GetEnumerator() foreach (char ch in chrs) yield return ch; class Program static void Main(string[] args) MyClass mc = new MyClass(); foreach (char ch in mc) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine();
A.
Run time error
B.
Compile time error
C.
Code runs successfully prints nothing
D.
Code runs successfully prints A, B, C, D
AnswerAnswer: Option D
Solution
Answer: Option D
No explanation is given for this question Let's Discuss on Board