adplus-dvertising
frame-decoration

Question

What will be the output of the code snippet?
class MyClass
{
    char ch = 'A';
    int e = 4;
    int k = 9;
    int z = 6;
    public IEnumerator GetEnumerator()
    {
        for (int i = 0; i < 26; i++)
        {
            if (i == e*k /z) yield break; 
            yield return (int)(ch + i);
        }
    }
}
class Program
{
    static void Main(string[] args)
    {
        MyClass mc = new MyClass();
        foreach(int ch in mc)
        Console.Write(ch + " ");
        Console.WriteLine();
        Console.ReadLine();
    }
}

a.

Compile time error

b.

Run time error

c.

65 66 67 68 69 70

d.

Code run successfully prints nothing

Answer: (c).65 66 67 68 69 70

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the output of the code snippet?

Similar Questions

Discover Related MCQs

Q. What are the advantages of the named iterator?

Q. Which namespace is mostly preferred for the operation of networking in C#?

Q. Which of the following are the classes defined by the namespace System.Net:

Q. Which of the following are the interfaces defined by the namespace System.Net:

Q. Which of the following are the classes that support the standard HTTP protocol ?

Q. Which of the following class/classes supports the task of uploading and downloading the file:

Q. How many ports of TCP/IP are reserved for specific protocols?

Q. How many bits are present in a single IP address?

Q. Which of the following is the full form of DNS?

Q. Which of the following classes is used to encapsulate IP address and DNS?

Q. Which of the following are the protocols defined by .NET runtime:

Q. What does URL stand for?

Q. Which of these exceptions is thrown by the URL class’s constructors?

Q. What does the following form define?

Protocol://HostName/FilePath?Query

Q. Which of these classes is used to encapsulate IP address and DNS?

Q. Which of these is a standard for communicating multimedia content over email?

Q. What does the following method specify?

public static WebRequest Create(string requestUriString)

Q. Which of these data members of HttpResponse class is used to store the response from a http server?

Q. Which of these classes is used to access actual bits or content information of a URL?

Q. What exception is thrown if the URI format is invalid?