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
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
SUNIL GUTTA
NA
1k
392.9k
duplicates in a string count ? help required
Feb 16 2014 2:34 AM
Hi
Please help me that my program gives correct output .
My program :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace part1
{
class AQ
{
static void Main()
{
int count; int z=0;
string s = "twinkle twinkle little star how i wonder what u star little ";
string[] arr = s.Split(' ');
int length = arr.Length - 1;
for (int i = 0; i < length; i++)
{
count = 0;
for (int j = 0; j < length; j++)
{
if (arr[i] == arr[j])
{
count += 1;
}
}
if (i > 0)
{
if (count > 1)
{
Console.WriteLine(" {0} - {1} ", arr[i], count);
}
}
Console.ReadKey();
}
}
}
I am getting output like :
twinkle-2
twinkle-2
star-2
star-2
little-2
little-2
BUT I NEED LIKE only
twinkle-2
star-2
little-2
Thank you
Reply
Answers (
6
)
WordFind Puzzle
Word prediction using n-gram technique