format exception was unhandled"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siddhanta
    New Member
    • Oct 2009
    • 33

    format exception was unhandled"

    Code:
    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]);
    }
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    I know you have been told this before: Please put [code] tags around your code in posts. Stop being lazy and expecting others to do it for you.

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      There is no question in your post. What are you asking of the volunteers here?

      Comment

      • siddhanta
        New Member
        • Oct 2009
        • 33

        #4
        hi,
        There is nothing being lazy, the only thing is that i thought its better to write point 2 point, so i didnt wrote much. but in line no. 14 the question was mentioned. Also, i should have mentioned that at top to highlight it.
        sorry to confuse you

        Comment

        • cloud255
          Recognized Expert Contributor
          • Jun 2008
          • 427

          #5
          Create a break point and step through the code, inspect the value varialbles[0], i'm pretty sure you'll see that it is not a float, this is why you get an error, the value provided cannot be converted into a float.

          Comment

          Working...