TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Number Of String Word Frequency In A Sentence Using C#
Vijayaragavan S
Aug 27
2016
Code
6
k
0
2
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
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#