So I have got a problem, my program is not functioning as I want it to...
I probably have a lot of errors in my code but what I want to do is that this code will take text from "latest.txt " (about five lines) and put it in a list. Later on, when this module is completed, my main program have a search function with a sort of "history of searches"(input ) and what I want is to make this module put the recent searched thing on index 0 of the list "rad" and increse the rest of the searches index with +1 and the last one that get index 10 will be removed.
Please help me!
Here's my code:
I probably have a lot of errors in my code but what I want to do is that this code will take text from "latest.txt " (about five lines) and put it in a list. Later on, when this module is completed, my main program have a search function with a sort of "history of searches"(input ) and what I want is to make this module put the recent searched thing on index 0 of the list "rad" and increse the rest of the searches index with +1 and the last one that get index 10 will be removed.
Please help me!
Here's my code:
Code:
using System; using System.IO; //using System.Text; using System.Collections.Generic; namespace read { class Program { public static void Read(/*string input*/)//comes later.. { string input="BBC - Top Gear";//TESTCODE List<string> lista = new List<string>(); string rad; string temp1; string temp2; using (StreamReader latest = new StreamReader ("latest.txt")) { while ((rad = latest.ReadLine()) != null) { lista.Add(rad); Console.WriteLine(rad + "\nAntal tecken: " //TESTCODE + rad.Length +"\n"); //TESTCODE if (rad == input) { Console.WriteLine("rad == inkommande");//TESTCODE for (int i=9; i>=0; i--) { //string utgående = utgående.Add(rad); if (i==9) { rad.Remove(9); Console.WriteLine("Prints line(rad): "); } Console.WriteLine("Moves position: "); for (int p=9; p>rad.Length; p--) { rad.ToCharArray(temp1); temp1=rad(p+1); Console.WriteLine(rad); } } } else { Console.WriteLine("rad != inkommande");//TESTCODE } } } } } }
Comment