This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
Snakity/Snakity/Resizer.cs

18 lines
527 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;
}
}
}