Arkanium77

Untitled

Oct 30th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1.         public static int[][] ReadAr(string path)
  2.         {
  3.  
  4.             int[][] a = null;
  5.  
  6.             using (FileStream fstream = File.OpenRead(path))
  7.             {
  8.                 // преобразуем строку в байты
  9.                 byte[] array = new byte[fstream.Length];
  10.                 // считываем данные
  11.                 fstream.Read(array, 0, array.Length);
  12.                 // декодируем байты в строку
  13.                 string textFromFile = System.Text.Encoding.Default.GetString(array);
  14.                 string[] textArray = textFromFile.Split('\n');
  15.                 string[][] textArray1 = new string[textArray.Length][];
  16.                 for (int i = 0; i < textArray.Length; i++)
  17.                 {
  18.                     textArray1[i] = textArray[i].Split(' ');
  19.                 }
  20.                 a = new int[textArray1.Length][];
  21.                 for (int i = 0; i < textArray1.Length; i++)
  22.                 {
  23.                     a[i] = new int[textArray1[i].Length];
  24.                     for (int j = 0; j < textArray1[i].Length; j++)
  25.                     {
  26.                         a[i][j] = Int32.Parse(textArray1[i][j]);
  27.                     }
  28.  
  29.                 }
  30.             }
Advertisement
Add Comment
Please, Sign In to add comment