C#-String字符串操作

贴代码。这些都是方法,不懂的留言

        private void StSplit()
        { 
            //检查所有字符串符号相同去掉
            Char[] delimiChars = { ' ', ',', '.', ':', '\t' };
            string text = "one\ttwo three:four,five six seven";
            tbText.Text = text;
            string[] words = text.Split(delimiChars);
            foreach (string s in words)
            {
                //数组遍历 组合
                st2 = st2 + s;
                log.Info("s===" + s);
                log.Info("st2==" + st2);
            }
            tbtext2.Text = st2;
            // 输出格式:onetwothreefourfivesixseven

        }


        public void St_Replace()
        {
            st = "123 123456 85797 \r\nabc def adcc abaaa";
            tbText.Text = st;
            //替换字符 全部替换
            String st2 = st.Replace("123", "333");
            tbtext2.Text = st2;
            /* 
             * *输出格式:333 333456 85797 
                          abc def adcc abaaa
             * * */
        }

 

posted @ 2017-05-24 00:07  Black-Hs  阅读(289)  评论(0编辑  收藏  举报