I have program that getting url from the user, and searching in the website for the words that most common.
public void url_input_Click(Object sender, EventArgs e)
{
string StringFromTheInput = TextBox1.Text;
var request_ = (HttpWebRequest)WebRequest.Create(StringFromTheInput);
WebResponse response = request_.GetResponse();
Stream data = response.GetResponseStream();
string content = String.Empty;
using (var client = new WebClient())
{
content= client.DownloadString(StringFromTheInput);
}
WordCount(content);
}
public static Dictionary<string, int> WordCount(string content, int numWords = int.MaxValue)
{
var delimiterChars = new char[] { ' ', ',', ':', '\t', '\"', '\r', '{', '}', '[', ']', '=', '/' };
return content
.Split(delimiterChars)
.Where(x => x.Length > 0)
.Select(x => x.ToLower())
.GroupBy(x => x)
.Select(x => new { Word = x.Key, Count = x.Count() })
.OrderByDescending(x => x.Count)
.Take(numWords)
.ToDictionary(x => x.Word, x => x.Count);
}
The issue is that what I have in "content" in the end of the function.
why it skip the linq line