Vidyalelo
C# Programming · Q78

Exception Handling in C Sharp

Programming · C# Programming · question 78

Q78

What will be the output of the following C# code? class list ArrayList array = new ArrayList(); public object this[int index] get if (index = array.Count) return null; else return (array[index]); set array[index] = value; public int Count get; set; class Program static void Main(string[] args) list list1 = new list(); list1[0] = "123"; list1[1] = " abc "; list1[2] = "xyz"; for (int i = 0; i<=list1.Count; i++) Console.WriteLine(list1[i]); Console.ReadLine();

A.
Compile time error
B.
Run time error
Answer
C.
123, abc, xyz
D.
0

Answer: Option B

Solution

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