Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Bounty
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Number Of String Word Frequency In A Sentence Using C#
WhatsApp
Vijayaragavan S
Aug 27
2016
6.2
k
0
2
using
System;
class
frequencyword {
public
static
void
Main() {
string
s1;
Console.WriteLine(
"Enter the String : "
);
s1 = Console.ReadLine();
Console.WriteLine(counting.CountStrFrequency(s1,
"test"
));
Console.ReadKey();
}
}
public
static
class
counting {
public
static
int
CountStrFrequency(
string
text,
string
pattern) {
int
count = 0;
int
i = 0;
while
((i = text.IndexOf(pattern, i)) != -1) {
i += pattern.Length;
count++;
}
return
count;
}
}
String Word Frequency
C#
Up Next
Number Of String Word Frequency In A Sentence Using C#