What Will Be The Output Of The Following C Codep Pre Langcsharp #463
What will be the output of the following C# code?</p> <pre><code class="language-csharp" line="1"> 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(); } } </code></pre>
This multiple choice question (MCQ) is related to the book/course gs gs108 CSharp. It can also be found in gs gs108 Indexers and Exception Handling - Introduction of Indexers - Quiz No.1.