public static Tikok Parse(string line) { string name = "", name1 = "", name2 = "", name3 = "", name4 = ""; using (StreamReader sr = new StreamReader(line)) { // Read the stream to a string, and write the string to the console. String lin = sr.ReadToEnd(); sr.Close(); TextReader reader = new StreamReader(line); string ine; while (null != (ine = reader.ReadLine())) //stop if readline return null { string[] arts = line.Split('\t'); //split the line into its parts name = arts[0]; name1 = arts[1]; name2 = arts[2]; name3 = arts[3]; name3 = arts[4]; } reader.Close(); Tikok ki = new Tikok(name, name1, name2, name3, name4); return(ki); { } } }
static tikokmanager() { initialize(); using (StreamReader sr = new StreamReader("assign.txt")) { // Read the stream to a string, and write the string to the console. String ine = sr.ReadToEnd(); sr.Close(); while (null != ine) //stop if readline return null { //Tikok.Parse(ine); Tikok.Parse(ine); } } }
public static void initialize() { Tikok t = new Tikok("richard", 34, "#elridge", audience.world); Tikok t1 = new Tikok("Dashawn", 24, "#Davis", audience.group); Tikok t2 = new Tikok("Bobby", 4, "#Black", audience.special); Tikok t3 = new Tikok("Dacy", 40, "#elridge", audience.world); Tikok t4 = new Tikok("Livistand", 39, "#callotto", audience.group); List <Tikok> tikos = new List <Tikok>() { t, t1, t2, t3, t4 }; foreach (Tikok item in tikos) { filename = item.ToString(); Console.WriteLine(item); } }