I am trying to create a simple unit converter which reads in the units from a file the file is layout like this:
ounce,gram,28.0
pound,ounce,16.0
...
It is read line by line like, 1 ounce is equal to 28 grams.
How would i go about comparing what the users inputs for to and from values and finding them in the array and * them by the correct factor.
Here is the code snippet of reading from the file.
Expand|Select|Wrap|Line Numbers
- {
- const char DELIM1 = '\r';
- string[] split1;
- int counter = 0;
- string line;
- System.IO.StreamReader filereader = new System.IO.StreamReader("C:/convert.txt");
- while ((line = filereader.ReadLine()) != null)
- {
- split1 = line.Split(DELIM1);
- Console.WriteLine(split1[0]);
- counter++;
- }
- filereader.Close();
- Console.ReadLine();
- }