Click here to Skip to main content
15,904,155 members

Comments by walidm38 (Top 2 by date)

walidm38 17-Oct-15 14:59pm View    
If my txt file contained similar rows to this:
1.1, 0.1836856, 5.6
3.3, -5.5, 43.44
-0.38162, 6.636666E-08, 3.1
1.01516E-07, 0.3695395, 1.5

How can read the file into a Tuple ?
Thank you

Hide Copy Code
var reader = new StreamReader(File.OpenRead(@"C:\MyFile.txt"));

while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(',');

var val1 = decimal.Parse(values[0], System.Globalization.NumberStyles.Float);
var val2 = decimal.Parse(values[1], System.Globalization.NumberStyles.Float);
var val3 = values[2];

Tuple<decimal,> myTuple = Tuple.Create<decimal,decimal,string>(val1,val2, val3);

}
walidm38 17-Oct-15 14:50pm View    
If my txt file contained simlar rows to these:
1.1, 0.1836856, 5.6
3.3, -5.5, 43.44
-0.38162, 6.636666E-08, 3.1
1.01516E-07, 0.3695395, 1.5

How can read the file into a Tuple ?
Thank you

Hide Copy Code
var reader = new StreamReader(File.OpenRead(@"C:\MyFile.txt"));

while (!reader.EndOfStream)
{
var line = reader.ReadLine();
var values = line.Split(',');

var val1 = decimal.Parse(values[0], System.Globalization.NumberStyles.Float);
var val2 = decimal.Parse(values[1], System.Globalization.NumberStyles.Float);
var val3 = values[2];

Tuple<decimal,> myTuple = Tuple.Create<decimal,decimal,string>(val1,val2, val3);

}