It's impossible. Think about it for just a second. If you have a generic type, say List<T> , T is a type parameter, and for specific instances of the generic type, you populate the type T
But int[3] not a type! Exactly, this is a array-creation-expression in a C # grammar.
If you want to restrict a type that can contain only three values, can I suggest Tuple<int, int, int> as the first cut? But even better, I recommend a type designed for representing RGB, like System.Drawing.Color (use Color.FromArgb(int, int, int) ) or, if necessary, your own custom type. The reason I'm leaning toward the latter is because not all Tuple<int, int, int> are valid RGB representations!
jason source share