am trying to read random words from a textfile . well have managed to read the words and display them in textblock problem is i only need to read words of certain
length only for example 5 to ten letters only
here is my code so far
private void Mywords()
{
var ResourceStream = Application.GetResourceStream(new Uri("TextFile1.txt", UriKind.Relative));
using (Stream Myfilestream = ResourceStream.Stream)
{
string s = "";
StreamReader myStreamReader = new StreamReader(Myfilestream);
s = myStreamReader.ReadToEnd();
s = s.Trim(); //tlbRandomWords.Text = s; // char[] delimiters = { '\n', '\r' };
string[] words = s.Split(); // int index = rand.Next(0,delimiters.Count());
if (s.Split().Length < 6)
{
tlbRandomWords.Text = words[rand.Next(words.Count())].ToUpper();
}
}
}