Windows Phone Developers

Tuesday, June 21, 2011

How to Convert a String to Array of Characters

The following snippet converts a string to a Character Array using CharArray

private static void String2CharArray()        {
            string s1 = "This is a string";
            Char[] ArrayofChars;
            ArrayofChars = s1.ToCharArray();
            Console.WriteLine(s1);
            foreach (char c1 in ArrayofChars)
                Console.WriteLine(c1);
        }
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

1 comment:

  1. or you could implment it with linq.

    var charArray = ("mystringvalue").ToArray();

    ReplyDelete