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
What is concrete class in c#?
Explain static class members.
What is the difference between ienumerable and enumerator?
What are winforms in c#?
Explain about Serialize and MarshalByRef?
What is the implicit name and type of the parameter that gets passed into the class set method?
Can extension methods access private members?
Why is static constructor called first?
Is list passed by reference c#?
Can we inherit a class with private constructor in c#?
What is an xsd file?
Explain use of abstract and sealed classes in c#?
How long will it take to learn c sharp?
Are there constructors in c sharp?
What are the types of attributes in c#?