public void Set(SquarePlace place, int value) { if (value < 1 && value > 9) { throw new ArgumentException("Falscher wert", nameof(value)); } switch (place) { case SquarePlace.A: Fields[0] = value; break; case SquarePlace.B: Fields[1] = value; break; case SquarePlace.C: Fields[2] = value; break; case SquarePlace.D: Fields[3] = value; break; case SquarePlace.E: Fields[4] = value; break; case SquarePlace.F: Fields[5] = value; break; case SquarePlace.G: Fields[6] = value; break; case SquarePlace.H: Fields[7] = value; break; case SquarePlace.I: Fields[8] = value; break; default: throw new ArgumentException("SquarePlace ist nicht vergeben", nameof(place)); } }
public int Get(SquarePlace place) { var output = place switch { SquarePlace.A => Fields[0], SquarePlace.B => Fields[1], SquarePlace.C => Fields[2], SquarePlace.D => Fields[3], SquarePlace.E => Fields[4], SquarePlace.F => Fields[5], SquarePlace.G => Fields[6], SquarePlace.H => Fields[7], SquarePlace.I => Fields[8], _ => throw new ArgumentException("SquarePlace ist nicht vergeben", nameof(place)), }; return(output); }