If I have a class like this:
public class ArrayContainer
{
public int[] Array { get; private set; }
public int Value { get; private set; }
public ArrayContainer()
{
Array = new int[] { 1, 2, 3, 4, 5 };
Value = 10;
}
}
This assures that Value will not be able to be changed outside the ArrayContainer class, but individual Array values will be able to be changed. What is the easiest workaround to this to assure that you can view values in Array, but not change them?
You could expose it as a read-only collection by using
Array.AsReadOnly.