Question
class MyClass { char ch = 'A'; public IEnumerable MyItr(int end) { for (int i = 0 ;i < end ;i++) yield return (char)(ch + i); } public IEnumerable MyItr(int begin, int end) { for (int i = begin ;i < end ;i++) yield return (char)(ch + i); } } class Program { static void Main(string[] args) { MyClass mc = new MyClass(); Console.WriteLine("Iterate the first 7 letters:"); foreach (char ch in mc.MyItr(7)) Console.Write(ch + " "); Console.WriteLine("n"); Console.WriteLine("Iterate letters from F to L:"); foreach (char ch in mc.MyItr(7, 12)) Console.Write(ch + " "); Console.WriteLine(); Console.ReadLine(); } }
a.
Iterate the first 7 letters:
A B C D E F G
Iterate letters from F to L:
G H I J K L
b.
Iterate the first 7 letters:
A B C D E F G
Iterate letters from F to L:
H I J K L
c.
Run time error
d.
Compile time error
Posted under C# programming
A B C D E F G
Iterate letters from F to L:
H I J K L
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?
View solution
Q. Which namespace is mostly preferred for the operation of networking in C#?
View solution
Q. Which of the following are the classes defined by the namespace System.Net:
View solution
Q. Which of the following are the interfaces defined by the namespace System.Net:
View solution
Q. Which of the following are the classes that support the standard HTTP protocol ?
View solution
Q. Which of the following class/classes supports the task of uploading and downloading the file:
View solution
Q. How many ports of TCP/IP are reserved for specific protocols?
View solution
Q. How many bits are present in a single IP address?
View solution
Q. Which of the following is the full form of DNS?
View solution
Q. Which of the following classes is used to encapsulate IP address and DNS?
View solution
Q. Which of the following are the protocols defined by .NET runtime:
View solution
Q. What does URL stand for?
View solution
Q. Which of these exceptions is thrown by the URL class’s constructors?
View solution
Q. What does the following form define?
Protocol://HostName/FilePath?Query
View solution
Q. Which of these classes is used to encapsulate IP address and DNS?
View solution
Q. Which of these is a standard for communicating multimedia content over email?
View solution
Q. What does the following method specify?
public static WebRequest Create(string requestUriString)
View solution
Q. Which of these data members of HttpResponse class is used to store the response from a http server?
View solution
Q. Which of these classes is used to access actual bits or content information of a URL?
View solution
Q. What exception is thrown if the URI format is invalid?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond C# programming? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!