matrixwithtest/MatrixProject/Matrix.cs
2024-10-08 13:42:11 +03:00

45 lines
905 B
C#

namespace MatrixProject;
public struct Matrix
{
private double[,] _data;
public int Rows { get => _data.GetLength(0);}
public int Columns { get => _data.GetLength(1);}
public Matrix(int rows)
{
_data = new double[rows, rows];
FillMatrixByNumber(0);
}
public Matrix(int rows, int columns) {
_data = new double[rows,columns];
FillMatrixByNumber(0);
}
public Matrix(int rows, int columns, int fillNumber)
{
_data = new double[rows, columns];
FillMatrixByNumber(fillNumber);
}
public double this[int row, int column] {
get => _data[row,column];
}
private void FillMatrixByNumber(int number) {
for (int i = 0; i < Rows; i++)
{
for (int j= 0; j < Columns; j++)
{
_data[i, j] = number;
}
}
}
}