Bir metin dosyasından tekrarlanan kelimeleri saymaya çalışıyorum ve bu hatayı alıyorum tanımını içermiyor .lines için ad system.windows.forms
olduğunu ... ve ben zaten kullanmıştı ... bu yüzden ... yanlış yerine Hatlarısystem.web.ui.webcontrols.textbox "satırları"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Click_Click(object sender, EventArgs e)
{
TextBox1.Lines =File.ReadAllLines("D:\\mun.txt")
Regex regex = new Regex("\\w+");
var frequencyList = regex.Matches(TextBox1.Text)
.Cast<Match>()
.Select(c => c.Value.ToLowerInvariant())
.GroupBy(c => c)
.Select(g => new { Word = g.Key, Count = g.Count() })
.OrderByDescending(g => g.Count)
.ThenBy(g => g.Word);
Dictionary<string, int> dict = frequencyList.ToDictionary(d => d.Word, d => d.Count);
foreach (var item in frequencyList)
{
Label1.Text =Label1.Text+item.Word+"\n";
Label2.Text = Label2.Text+item.Count.ToString()+"\n";
}
}
}
gösterilecek
<br />
kullanıyor. Hata cevabı söylüyor. – Hendry