Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 is concrete class in c#?

840


Explain static class members.

990


What is the difference between ienumerable and enumerator?

854


What are winforms in c#?

858


Explain about Serialize and MarshalByRef?

901


What is the implicit name and type of the parameter that gets passed into the class set method?

820


Can extension methods access private members?

850


Why is static constructor called first?

847


Is list passed by reference c#?

841


Can we inherit a class with private constructor in c#?

997


What is an xsd file?

877


Explain use of abstract and sealed classes in c#?

797


How long will it take to learn c sharp?

881


Are there constructors in c sharp?

902


What are the types of attributes in c#?

907