I am trying to write some code that fills a label with randomly generated Quotes..I can do this , the problem I am having is removing the item from the list once it is used to fill the label....my code below doesnt work as I thought it would.....
any help would be appreciated
InkedGFX
List<string> message = new List<string>(); Random rand = new Random(); // initialize the random class StreamReader messageReader = new StreamReader("messages.txt"); string line = ""; while (line != null) { line = messageReader.ReadLine(); message.Add(line); } for (int i = 0; i < message.Count; i++) { int removeMe = rand.Next(0, message.Count); message.RemoveAt(removeMe); lblMessage.Text = message[rand.Next(0, i)]; }
any help would be appreciated
InkedGFX