Random meaning word with Linq

An example with LinQ

string RandomWord(int length)
{
string libWord = @”Basic concepts History Formal language theory Formal definition Expressive power and compactness Deciding equivalence of regular expressions Syntax”;
string original = libWord.Replace(System.Environment.NewLine, ” “);
var res = from n in original.Split(Convert.ToChar(” “)) where (n.Length == length || length == 0) && n.Trim() != “” && n.Trim() != “” && n.Trim() != “”
select n;
return res.ElementAt(new Random().Next(0 ,res.Count()));
}

Have fun with FunnyLinQ ^_^

Leave a comment