2021-03-01から1ヶ月間の記事一覧
public static class Utility { /// <summary> /// 0~maxの範囲のIndex を返す /// 負の値にも対応 /// </summary> public static int LoopIndex(int index, int max) { var ret = index % max; if (index < 0) ret += max; return ret; } } 実行例 Utility.LoopIndex(10, 20); …