rendered paste bodyusing System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
public class Welcome1
{
private const int FRANCAIS = 0;
private const int ENGLISH = 1;
public static void Main(string[] args)
{
Welcome1 ceci = new Welcome1();
string fileName = "mots.txt";
if (File.Exists(fileName))
{
FileStream lesMots = new FileStream(fileName, FileMode.Open, FileAccess.Read);
StreamReader fileReader = new StreamReader(lesMots);
string[,] pairList = ceci.fillArray(fileReader);
}
else Console.WriteLine("file open failed.");
}
private Dictionary<string,string> fillTheArray(StreamReader reader)
{
Console.WriteLine("go fillArray go!");
Dictionary<string, string> lesPairs = new Dictionary<string, string>();
string flutter = reader.ReadLine();
string key = null;
string value = null;
int split = 0;
do
{
flutter = reader.ReadLine();
if (flutter != null)
{
split = flutter.IndexOf("-");
key = flutter.Substring(0, split).Trim();
value = flutter.Substring(split + 1).Trim();
lesPairs.Add(key, value);
}
}while (flutter != null);
return lesPairs;
}
private string[,] fillArray(StreamReader reader)
{
List<string> wordList = new List<string>();
string newLine = reader.ReadLine();
do
{
wordList.Add(newLine);
newLine = reader.ReadLine();
}
while (newLine != null);
int wordlistLength = wordList.Count;
string[,] output = new string[2, wordlistLength];
for (int i = 0, split = 0; i < wordlistLength; ++i)
{
newLine = wordList[i];
split = newLine.IndexOf("-");
output[FRANCAIS,i] = newLine.Substring(0, split).Trim();
output[ENGLISH,i] = newLine.Substring(split+1);
}
return output;
}
}