首页 > 编程语言 > 详细

c#语言-Split拆分

时间:2016-04-23 21:24:43      阅读:234      评论:0      收藏:0      [点我收藏+]


static void Main(string[] args) { int[,] cj = new int[3,4]; Console.WriteLine("学号\t语文\t数学\t外语"); for (int i = 0; i < 3; i++) { Console.Write(i + 1); Console.Write("\t"); string s = Console.ReadLine(); string[] str = s.Split(‘ ‘,‘\t‘,‘,‘);/////Split(‘ ‘,‘‘,‘‘......)或Split(‘,‘),Split(‘\t‘)等等很多种都可以达到同样的目的。
目的就是将字符串拆分成n串;
int yw = Convert.ToInt32(str[0]); int sx = Convert.ToInt32(str[1]); int wy = Convert.ToInt32(str[2]); Console.WriteLine(yw + sx + wy); } // string s = Console.ReadLine(); //int yw, sx, wy; //string[] str = s.Split(‘ ‘,‘,‘,‘-‘,‘\t‘); //yw = Convert.ToInt32(str[0]); //sx = Convert.ToInt32(str[1]); //wy = Convert.ToInt32(str[2]); //Console.WriteLine("语文:{0},数学:{1},外语:{2}", yw, sx, wy); }

 

c#语言-Split拆分

原文:http://www.cnblogs.com/koker/p/5425462.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!