Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace ConsoleApp6
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[,] map = ReadMap("map1");
- }
- static void DrawMap(char[,] map)
- {
- for (int i = 0; i < map.GetLength(0); i++)
- {
- for (int j = 0; j < map.GetLength(1); j++)
- {
- Console.Write(map[i, j]);
- }
- Console.WriteLine();
- }
- }
- static char[,] ReadMap(string mapName)
- {
- string[] newFile = File.ReadAllLines($"Maps/{mapName}.txt");
- char[,] map = new char[newFile.Length, newFile[0].Length];
- for (int i = 0; i < map.GetLength(0); i++)
- {
- for (int j = 0; j < map.GetLength(1); j++)
- {
- map[i, j] = newFile[i][j];
- }
- }
- return map;
- }
- }
- }
- /*
- Необработанное исключение: System.IndexOutOfRangeException: Индекс находился вне границ массива.
- в System.String.get_Chars(Int32 index)
- в ConsoleApp6.Program.ReadMap(String mapName) в C:\Users\User\source\repos\ConsoleApp6\ConsoleApp6\Program.cs:строка 39
- в ConsoleApp6.Program.Main(String[] args) в C:\Users\User\source\repos\ConsoleApp6\ConsoleApp6\Program.cs:строка 14*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement