"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Thursday, October 7, 2010

splitting a sentence into characters by characters using CharEnumerator

Hi everybody,
last day i faced a need like this. to split all characters in a sentence one by one and i used CharEnumerator for that it helped to do it easily.


Code


    protected void CharEnumerator_Demo()
    {
        string _d = "My name is Arun";
        Response.Write("Input:My name is Arun");
        Response.Write("<br />");
        Response.Write("OutPut:");
        Response.Write("<br />");
        CharEnumerator chs = _d.GetEnumerator();
        while (chs.MoveNext())
        {
            Response.Write(chs.Current);
            Response.Write("<br />");
        }
    }


Output






















Have a nice day... 'N happy Coding :)

No comments: