using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
public class Starter {
public static void Main() {
int[] zArray = { 1, 2, 3, 4 };
zArray[1] = 10;
ReadOnlyCollection<int> roArray = Array.AsReadOnly(zArray);
foreach (int number in roArray) {
Console.WriteLine(number);
}
roArray[1] = 2; // compile error
}
}
|