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

What is serialization in dot net?

662


What are mutable and immutable types in c#?

655


Explain metadata in c#.

661


what is inheritance and an example in vb.net and c# of when you might use it?

709


Why do we need to override in c#?

707


What is a console operator?

654


What is verbatim string literal in c#?

645


Why use a singleton instead of static methods?

629


Why do we need abstraction in c#?

661


What is predicate c#?

712


What is a three-tier application.

776


What are generics in c#.net?

775


How many root nodes are there in an xml document?

639


What is the difference between constant and readonly in c#?

620


What is parameters in c#?

684