hi everyone,

I am reletively new to c sharp and have a question regarding a console application I have created. I have a text file which contain 16 records which i want to sort in dob order. I was wandering how i could split the data so when i run the application i will be able to scale through the dates in order of date of birth, the first line of the text file looks like this


I have read the file using streamreader but I am stuck on where to go from here. Any help will be greatly appreciated

Many thanks

Please could you post what you have so far please? Show us something we can work on, without having to guess what you're using!

Also, have a look into the LINQ library which could sort the DOB easier.

Hope this helps =)

using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.IO;

namespace ConsoleApplication5
    class Program
        static void Main(string[] args)
            StreamReader myFile = new System.IO.StreamReader(@"C:\Documents and Settings\Alane\My Documents.txt");
            string str1 = myFile.ReadToEnd().ToString();
            string[] str = str1.Split(new char[] { ',' });
            string name = str[0];
            string name2 = str[1];
            string date = str[2];
            string date2 = str[3];

I Have 15 records on the text file so would i possibly need 15 arrays? many thanks

Hey, can you post what you have in your "My Documents.txt" file and, for future reference put your code in tags (Y)

Also, you wouldn't need 15 arrays, only one array that stores the values.. That's the point of an array! :)



If you read the data into a class and put that class in a list, you can easily sort by a particular field.
Do you have any restrictions on the types of technology you can use?

I was looking to keep the code as simple as possible as I am a newbie, I was looking to use basic structures and arrays. I want the program to have a key to scroll to the next record and back, Many thanks

If you are willing to split (and re-order) the data as you read it (putting the date part first), you can put it in a List<string> and then just call .Sort();
... but I just noticed one row has a 3-part name. Was that intentional?