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

What type of data type conversion happens when the compiler encounters the following code?

533


How would you describe encapsulation in c#?

482


Which class comes after the SortedList class?

566


What is alias in c#?

534


What is decimal in c#?

503






What are cshtml files?

486


What are the types of methods in c#?

457


What is interpolation in programming?

486


What is cosole application?

570


What is difference between list and dictionary in c#?

462


What do you mean by synchronous and asynchronous operations?

473


explain the features of static/shared classes.

497


What are the properties of a string class?

515


What does type safe mean in c#?

505


if you do have a stack overflow profile.what is your ranking?

1480