Best way to handle elements of a private array
If you expose it via a public property then it's not a "private" array any more:it's part of the public interface.

If resetting its elements is something that you want clients to do, I'd choose the first option (because it's simplest).

Or, these ...

public void SetColor(int id, Color value) { ... }
public bool GetColor(int id, out Color result) { ... }


... could perhaps be done using indexers ...

public Color this[int id]
{
    get { ... }
    set { ... }
}


... but that's not very different from exposing the array (and there can be only one indexer of a given signature, which doesn't work if there's more than one array to be exposed).

Here's a blog post on the topic: http://blogs.msdn.com/b/ericlippert/archive/2008/09/22/arrays-considered-somewhat-harmful.aspx

Another possibility (I've just thought of it, haven't tested/researched this idea) might be to pass the array into the constructor:

public sealed class Emitter
{
    private readonly Color[] _colors;
    public Emitter(Color[] colors) { _colors = colors; }
}


The reason excuse for that is that so that whoever constructs Emitter has the array, can keep that array, and can (evilly) modify that array after it has used it to construct Emitter.

Color[] colors = new Color[8];
Emitter emitter = new Emitter(colors);
colors[0] = Color.Red; // changes constents of array inside the Emitter


The official recommendation is to use a List&lt;Color&gt; instead of a Color[] array, and return IList&lt;Color&gt; ... conceptually similar IMO, but you won't get the compiler and FxCop warnings.

public sealed class Emitter
{
    private readonly List&lt;Color&gt; _colors;
    public IList&lt;Color&gt; Colors { get { return _colors; } }
}




As @svick noted in a comment below, because arrays implement the IList&lt;T&gt; interface, you can also do this:

public sealed class Emitter
{
    private readonly Color[] _colors;
    public IList&lt;Color&gt; Colors { get { return _colors; } }
}


IList&lt;T&gt; supports the API you want (i.e. an indexer property). Using IList&lt;T&gt; supresses the compiler warning. It may be less intuitive to the client/user though (who may think, incorrectly, that the IList&lt;T&gt; would allow them to change its size).