mirror of
https://onedev.fprog.nl/AioNet
synced 2025-12-21 04:28:37 +01:00
40 lines
982 B
C#
40 lines
982 B
C#
using System;
|
|
|
|
namespace AioNet.DataStructures
|
|
{
|
|
public static class Matrix
|
|
{
|
|
public static int NumberOfRows<T>(this T[,] source)
|
|
{
|
|
return source.GetLength(0);
|
|
}
|
|
|
|
public static int NumberOfColumns<T>(this T[,] source)
|
|
{
|
|
return source.GetLength(1);
|
|
}
|
|
|
|
public static T[][] ToJaggedArray<T>(this T[,] source)
|
|
{
|
|
int rows = source.NumberOfRows();
|
|
int columns = source.NumberOfColumns();
|
|
|
|
T[][] jaggedArray = new T[rows][];
|
|
|
|
for (int row = 0; row < rows; row++)
|
|
{
|
|
T[] currentRow = new T[columns];
|
|
|
|
for (int column = 0; column < columns; column++)
|
|
{
|
|
currentRow[column] = source[row, column];
|
|
}
|
|
|
|
jaggedArray[row] = currentRow;
|
|
}
|
|
|
|
return jaggedArray;
|
|
}
|
|
}
|
|
}
|