Files
Shogi/Gameboard.ShogiUI.BoardState/Array2D.cs
2021-02-23 18:03:23 -06:00

30 lines
613 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Gameboard.ShogiUI.BoardState
{
public class Array2D<T> : IEnumerable
{
private readonly T[] array;
private readonly int width;
public Array2D(int width, int height)
{
this.width = width;
array = new T[width * height];
}
public T this[int x, int y]
{
get => array[y * width + x];
set => array[y * width + x] = value;
}
IEnumerator IEnumerable.GetEnumerator() => array.GetEnumerator();
}
}