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();
原文地址:https://www.cnblogs.com/zywf/p/4501927.html