MCQOPTIONS
Saved Bookmarks
| 1. |
Choose the output for the given set of code? class list { ArrayList array = new ArrayList(); public object this[int index] { get { if (index < 0 || 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 |
| C. | 123, abc, xyz |
| D. | 0 |
| Answer» C. 123, abc, xyz | |