public static void SaveWorldData(Tile[,] tiles, string path) { using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create))) { int xLen = tiles.GetLength(0); int yLen = tiles.GetLength(1); writer.Write(xLen); writer.Write(yLen); for (int i = 0; i < xLen; i++) { for (int j = 0; j < yLen; j++) { WriteTile(writer, tiles[i, j] ?? new Tile()); } } } }