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

How can we sort the elements of the array in descending order?

528


Can hashset contain duplicates c#?

462


What is response redirect in c#?

478


Why can’t struct be used instead of class for storing entity?

477


Describe a Struct ?

541






What is type system in c#?

514


Is comparable a functional interface?

501


In object oriented programming, how would you describe encapsulation in c#?

537


What is Co- and Contra-Variance in C#?

540


What is method and function in c#?

494


What is serialization in dot net?

476


How to sign an assembly with strong name?

577


What are sessions in c#?

491


What does break do in loop?

490


How many bits is int32?

490