日期:2014-05-18  浏览次数:21014 次

把一个文本框中的值取出来怎么赋值给一个数组?
如:String str ="abcdefg";怎么把每一个字母赋值给数组呢?

------解决方案--------------------
C# code

string[] strs = new string[2];
            strs[0] = "abc";
            strs[1] = "def";
            ArrayList al = new ArrayList();
            foreach (var item in strs)
            {
                char[] ArrayItem= item.ToCharArray();
                al.AddRange(ArrayItem);
            }

            foreach (var item in al)
            {
                Console.WriteLine(item);
            }

------解决方案--------------------
C# code
  string[] str = new string[3];
            str[0] = "abcdefg";
            str[1] = "hijklmn";
            str[2] = "opqrstu";

            for (int i = 0; i < str.Length - 1; i++)
            {
                string s = str[i];
                for (int k = 0; k < s.Length - 1; k++)
                {
                    string[] SaveStr = new string[s.Length-1];
                    SaveStr[k] = Convert.ToString(s[k]);
                }
            }