float[] x = new float[10000];
float[] y = new float[10000];
int c=0;
using (StreamReader sr = new StreamReader("e: \\CuPeak.dat"))
{
while (!sr.EndOfStream)
{
string s = sr.ReadLine();
string[] variables = s.Split(' ');
x[c] = float.Parse(variables[0]);//run time ERROR in this line " format exception was unhandled"
y[c] = float.Parse(variables[1]);
Console.WriteLine(x[0]);
}
}
sidd. 0
Light Poster
Recommended Answers
Jump to PostThis is probably caused by the variables[0] not being formatted as a float. To solve this you need to make sure that all the lines in the file actually contains "{float} {float}" on every single line.
All 3 Replies
Alxandr 5
Junior Poster in Training
sidd. 0
Light Poster
kvprajapati 1,826
Posting Genius Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.