how can i return string by vilating duplicates(inpyt like
asdfsda but output should be 2a2d2sf and 2a,2d,2s,f)

Answer Posted / hari

we can modify the previous answer to make it efficient...
check it..

string x = "asdfsdaaasasa";
string output = "";
int count = 0;
IEnumerator ie = x.GetEnumerator();
IEnumerator iee = x.GetEnumerator();
while(ie.MoveNext())
{
if (!output.Contains(ie.Current.ToString()))
{
while(iee.MoveNext())
{
if ((char)ie.Current == (char)iee.Current)
{
count++;
}
}
iee.Reset();
output = output + count + ie.Current;
count = 0;
}
}
Console.WriteLine(output);

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is boxing an implicit conversion?

545


What is sealed class in c#?

521


How do I open the console?

609


What is the advantage of static class in c#?

511


What is meant by console programming?

477






List down the reason behind the usage of c# language.

650


What's the difference between system.string and system.text.stringbuilder classes?

529


What is the difference between int16 and int32 in c#?

476


How many parameters can a method have c#?

486


What are the differences between static, public and void in c#?

570


What is dataadapter c#?

481


how to prevent a class from being inherited in c#.net?

516


What is value c#?

462


What does protected internal access modifier mean?

549


Can you inherit multiple abstract classes in c#?

494