C#字符串分割

 string str = "af adsf e4afef3 _asdf $adsf";
            char[] chr = { ' ', '_', '$' };
            //StringSplitOptions.RemoveEmptyEntries去掉空格
            string[] st=str.Split(chr,StringSplitOptions.RemoveEmptyEntries);

            string s2 = "2018-12-12";
            char[] cr={'-'};
           string[] year= s2.Split(cr, StringSplitOptions.RemoveEmptyEntries);
            Console.WriteLine("{0}年{1}月{2}日",year[0],year[1],year[2]);
            Console.ReadKey();

 

posted @ 2015-05-13 22:34  自由无风  阅读(176)  评论(0编辑  收藏  举报