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

Answer Posted / adityakiran

I suppose this question is intended to test the knowledge on
IEnumerator. The following piece of code may give the
required first part of the output...

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

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which types of inheritances does c# support?

465


What are primitive data types in c#?

522


What is the difference between c and c# programming?

447


Explain the mechanism of VB.NET/C# achieve polymorphism?

539


how dot net compiled code will become platform independent?

529






What do you mean by serialization in .NET?

554


How do you implement thread synchronization in c#?

463


What does void do in c#?

521


Explain About Iunknown interface Queue

547


What is a multicast c# delegate?

515


What is the object class in c#?

488


How will you allow a class to be inherited, but prevent the method from being over-ridden?

524


What is a race condition?

495


What is array and arraylist?

544


Does main have to be static c#?

488