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
6 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Lakshmanan Sethu SankaranarayanPosted Feb 16, 2014, 3:05 AM
SUNIL GUTTAPosted Feb 16, 2014, 6:00 AM
Modified something like this
Regards
Shweta LodhaPosted Feb 16, 2014, 4:18 AM
Lakshmanan Sethu SankaranarayanPosted Feb 16, 2014, 3:50 AM
SUNIL GUTTAPosted Feb 16, 2014, 3:43 AM
SUNIL GUTTAPosted Feb 16, 2014, 3:27 AM