hi guys ! newbie here
I need help debugging my error.
currently using .Net 4.0 VS2010
Here is an screen shot of the error
// Runner class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ListOfRunners
{
class Runner
{
public string Name { get; set; }
public int Time { get; set; }
public int Age { get; set; }
}
}
// Main Program
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ListOfRunners
{
class Program
{
static void Main(string[] args)
{
Runner runner = new Runner();
List<Runner> listRunner = new List<Runner>();
StreamReader myReader = new StreamReader("TextFile1.txt");
string line = "";
do
{
line = myReader.ReadLine();
if (line != null)
{
listRunner.Add(GetRunnerDetails(line));
}
} while (line!= null);
myReader.Close();
Console.ReadLine();
}
public static Runner GetRunnerDetails(string line)
{
Runner runner = new Runner();
line = line.Trim();
//to get the name
int delimiterIndex = line.IndexOf(" ");
runner.Name = line.Substring(0, delimiterIndex);
line = line.Replace(runner.Name, "");
line = line.Trim();
//to get age
delimiterIndex = line.IndexOf(" ");
runner.Time = int.Parse(line.Substring(0, delimiterIndex));
line = line.Replace(runner.Time.ToString(), "");
line = line.Trim();
//to get the time
delimiterIndex = line.IndexOf(" ");
runner.Age = int.Parse(line.Substring(0, delimiterIndex));
line = line.Replace(runner.Age.ToString(), "");
line = line.Trim();
return runner;
}
}
}
code is attached