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 are the types of constructors?

513


What is int tryparse in c#?

529


What are the Types of instancing properties and explain each. Explain the difference between multiuse,singleuse and globalmultiuse and which is default

560


What is interface inheritance in c#?

524


Can you use all access modifiers for all types?

543






What is the difference between method and function in c#?

449


Why should I use interface in c#?

501


What are the variables in c#?

506


What is a type c#?

503


What is c# windows form application?

504


Write the difference between TypeOf and GetType?

597


What are the different ways of method can be overloaded?

462


What is the solution if you need to manipulate sets of items?

472


How to use reflection to call generic method?

504


What Is The Smallest Unit Of Execution In .net?

530