Vidyalelo
C# Programming · Q170

Miscellaneous in C Sharp

Programming · C# Programming · question 170

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
Answer

Answer: Option D

Solution

Answer: Option D
No explanation is given for this question Let's Discuss on Board