1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| using System.Text;
using System.IO;
using System;
using System.Collections.Generic;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
// Read All line from file
string[] allLine = File.ReadAllLines(@"C:\Users\aboubakr\Desktop\tfe ayoub\test 2 25electrodes.txt");
int rowCount = allLine.Length; // nbre de ligne
int columnCount = allLine[0].Split(new char[] {},
StringSplitOptions.RemoveEmptyEntries).Length; // nbre de colonne
string[,] matrix = new string[rowCount, columnCount];
// dispaly data
for (int rowCounter = 0; rowCounter < rowCount; rowCounter++)
{
string[] line = allLine[rowCounter].Split('\t');
for (int columnConter = 0; columnConter < columnCount; columnConter++)
{
matrix[rowCounter, columnConter] = line[columnConter]; // matrix : matrice contenant chaque ligne de file
Console.Write(matrix[rowCounter, columnConter]);
Console.Write("\t");
}
Console.Write("\n");
}
int a, b,c;
a = Convert.ToInt32(matrix[1,2]) ;
b= Convert.ToInt32(matrix[1,3]);
c = a + b;
Console.WriteLine(c);
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
}
}
} |
Partager