What is CharEnumerator in C#?

 Posted by Raja on 2/15/2010 | Category: C# Interview questions | Views: 5183
Answer:

CharEnumerator is an object in C# that can be used to enumerate through all the characters of a string. Below is the sample to do that


string str = "my name";

CharEnumerator chs = str.GetEnumerator();
while(chs.MoveNext())
{
Response.Write(chs.Current);
}


Moderator: please do not move this to Code section, this is a typical interview question that was asked :)


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response