C# Corner
Tech
News
Videos
Forums
Trainings
Books
Live
More
Interviews
Events
Jobs
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
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
Find The Most Occurred Word In String
WhatsApp
Ritesh Singh
Aug 13
2016
812
0
0
public
string
ReturnRepeatElement(
string
str)
{
int
i, j;
int
maxcount = 0;
string
[] strArray =
new
string
[]{};
string
_element=
string
.Empty;
strArray = str .Split(
' '
);
for
( i = 0; i < strArray.Length; i++)
{
int
count = 0;
for
( j = 0; j < strArray.Length;j++ )
{
if
(strArray[i] == strArray[j])
{
count++;
}
}
if
(maxcount < count)
{
maxcount = count;
_element=strArray[i];
}
}
return
_element;
}
C# array
Up Next
Find The Most Occurred Word In String