public void docfile() { int i = 0; string s; System.IO.FileStream fr; if (File.Exists(@"../../DSCD2.txt") == false) { fr = new System.IO.FileStream(@"../../DSCD2.txt", FileMode.Create); } else { fr = new System.IO.FileStream(@"../../DSCD2.txt", FileMode.Open, FileAccess.Read); } StreamReader sr = new StreamReader(fr); do { s = sr.ReadLine(); if (s == null) { break; } Array.Resize <NGUOICHOI>(ref ng, ng.Length + 1); ng[i] = new NGUOICHOI(); ng[i].Ten = s; s = sr.ReadLine(); ng[i].Giatri = int.Parse(s); i++; } while (s != null); sr.Close(); fr.Close(); }
public void sapxep() { for (int i = 0; i < ng.Length - 1; i++) { for (int j = i + 1; j < ng.Length; j++) { if (ng[i].Giatri < ng[j].Giatri) { NGUOICHOI a = ng[i]; ng[i] = ng[j]; ng[j] = a; } } } }