View Full Version : تعداد تکرار کلمه ها موجود در یک فایل text
zare69
پنج شنبه 19 اسفند 1389, 09:33 صبح
دوستان سلام
من می خوام تعداد تکرار کلمه موجود تو یه فایل textبدست بیارم کسی میتونه به من کمک کنه خیلی حیاتی.
با تشکر:متفکر:
rainlover
پنج شنبه 19 اسفند 1389, 20:45 عصر
static void Main(string[] args)
{
string txt = "متن اصلی";
string statement = "عبارت مورد جستجو";
int count = 0;
int length=statement.Length;
while (txt.Contains(statement))
{
txt = txt.Remove(txt.IndexOf(statement), length);
count++;
}
Console.Write(count);
Console.ReadLine();
}
Saman_12
پنج شنبه 19 اسفند 1389, 22:05 عصر
شاید این منطقی نباشه :
private int GetNumofStr(string Sentence, string Str)
{
return Sentence.Split(Str.ToCharArray()).Length - 1;
}
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.