18 lines
524 B
C#
18 lines
524 B
C#
using System;
|
|
|
|
namespace Snakity
|
|
{
|
|
public static class Resizer
|
|
{
|
|
public static T[,] Resize<T>(this T[,] original, int rows, int cols)
|
|
{
|
|
T[,] newArray = new T[rows,cols];
|
|
int minRows = Math.Min(rows, original.GetLength(0));
|
|
int minCols = Math.Min(cols, original.GetLength(1));
|
|
for(int i = 0; i < minRows; i++)
|
|
for(int j = 0; j < minCols; j++)
|
|
newArray[i, j] = original[i, j];
|
|
return newArray;
|
|
}
|
|
}
|
|
} |