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
Which attribute adorn a test class to be picked up by the NUnit GUI in the NUnit test framework?
Do loops c#?
What is a private class in c#?
Why generics are used in c#?
What is a method signature c#?
What is variable in c#?
What is command object in c#?
What is Satellite Assemblies ?
When should you use generics?
What are primitive types in c#?
What is the difference between xml documentation tag?
Explain the working of serialization?
What are object pooling and connection pooling and difference between them?
What is cookies in c# asp net?
What is serializable in c#?