THX ALL OF YOU .USING LIST<> INSTEAD ARRAYLIST IS RLY HELPFULL
So i heave a struct, wich contain information about worker, fio-name of worker, dolj-his job, staj-how much he working on this job and zp-how much money he takes, this info i keep in file with strings, expl:Nick, road-worker, 5,200. I have 8 thoose string like expl, and i need to sort them by the name of worker, using arraylist and struct, plz help !
//Struct
public struct Worker
{
public string FIO;
public string Dolj;
public int Staj;
public int Zp;
public Worker(string fi, string dj, int st, int zrp)
{
FIO = fi;
Dolj = dj;
Staj = st;
Zp = zrp;
}
//reading from file
ArrayList listw = new ArrayList();
Worker W;
StreamReader file= new StreamReader("Workers.txt", Encoding.Default);
;
while (!file.EndOfStream)
{
string[] wtemp = file.ReadLine().Split(',');
W = new Worker(wtemp[0],wtemp[1],Convert.ToInt32(wtemp[2]),Convert.ToInt32(wtemp[3]));
listw.Add(W);
}
//display listw
//!!!!! So here i need to sort arraylist or struct by FIO (name of worker)
// Arraylist - listw
// (Name,job,years,money)
// (Name,job,years,money) --Sort by name!
foreach (Worker outworker in listw)
{
Console.WriteLine
(outworker.FIO,outworker.Dolj,outworker.Staj,outworker.Zp);
}