matrixwithtest/MatrixProject/Matrix.cs

45 lines
905 B
C#
Raw Normal View History

2024-10-08 10:42:11 +00:00
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;
}
}
}
}