lwj_C#_周总结2 字符串练习

来源:互联网 发布:考研知乎 编辑:程序博客网 时间:2024/04/30 23:53
            
            string str = "Because of you i never stray to far from the sidewalk";
            string [] str_1 = str.Split (' ');

            string new_str = "";//空字符串==长度为0  和null不同

            for (int i = 0; i < str_1.Length ; i++) {
                if (str_1[i] == "to") {
                    str_1[i] = "too";//数组可以直接赋值
                }
                new_str += (str_1 [i] + " ");
            }
            foreach (char i in new_str) {
                Console.Write(i);
            }
原创粉丝点击