public Matrix(int width, int height, params Directions[] validDirections) { validDirections_ = validDirections; height_ = height; width_ = width; elements_ = new MatrixElem[width, height]; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) elements_[i, j] = new MatrixElem(); } }
public Matrix(string matrixStr, params Directions[] validDirections) { var lines = matrixStr.Split('\n'); height_ = lines.Length; int j = 0; foreach (var line in lines) { var numbers = line.Split(','); width_ = numbers.Length; if (elements_==null) elements_ = new MatrixElem[width_,height_]; for (int i = 0; i < width_; i++) { elements_[i, j] = new MatrixElem() {Value = int.Parse(numbers[i])}; } j++; } validDirections_ = validDirections; }