Hi guys, I m making an small aplication for buses but i got stuck with the string array conversion to a timespan array, i have to convert it i order to compare times later on but i don t know how... Here is the code

    string line;
        TimeSpan [] array;
        OpenFileDialog ofd =new OpenFileDialog();
        if (ofd.ShowDialog()==DialogResult.OK)
        {
             StreamReader str=new Streamreader(File.OpenRead(ofd.FileName));
             while (!sr.EndOfStream)
             {
                 line=sr.ReadLine();
                 string [] array=line.split(';') // time stored inside , format-->hours:minutes, example 08:10
             }

If you ve got any other suggestions in order to avoid the timespan class but to be able to work with times later on then please advice.

while (!sr.EndOfStream)
                {
                    line = sr.ReadToEnd();
                    string[] array = line.Split(';');  // times stored inside ,,08:10, 08:30...
                    TimeSpan[] array1 = new TimeSpan[array.Length];
                    for (int i = 0; i < array1.Length; i++) 
                    {
                        array1[i] = TimeSpan.Parse(array[i]);
                    }
                    for (int i = 0; i < array.Length; i++) 
                    {
                        MessageBox.Show(array1[i].ToString());
                    }
                 }

i found the answer to my question , any other suggestion will be helpfull in order to make this more convenient for further usage.

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.