读取按某种分隔符分隔的字符

时间:2015/12/3 14:59:00来源:互联网 作者:flyso 点击: 895 次
string birthday = "2009-08-08";

                char[] spliter = { '-', ';', ',' };
                string[] sItems = birthday.Split(spliter);
                string str_years = sItems[0];
                string str_month = sItems[1];
                string str_day = sItems[2];


样可以分别读出年月日单独的字符                

想要得到分割后的值,用for语句; 

      string[] s = ("中,华,人,民,共,和,国").Split(',');
            for(int i=0;i <s.Length;i++)
            {
                System.Console.WriteLine(s[i]);
            }
            Console.ReadLine(); 


Copyright © 2005 - 2016 flyso.cn. 飞搜 版权所有 鄂ICP备11002783号-3