c#语言-Split拆分
2016-04-23 20:22
501 查看
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#学习之数组 36选7随机数不重复/折半取余
- C#引用C++代码
- C# comboBox怎么修改text的值(在dropdownlist下)
- c# 获取网页源码
- [C#]时间比较的两种方法
- c# 获得文字的像素宽度
- C#多线程简单例子讲解
- 【CodeHunt】噢,听说今年的CH又开始了
- C#第7周泛型类的使用
- C#第八周异常处理
- C#反射,特性结合使用
- c# sftp 库 ssh.net, sharpssh
- c# sftp 库 Chilkat
- C# 中英文与Unicode之间的相互装换
- 【C#】System.IO.Stream 中flush的用法
- C#正则表达式
- C# 中的委托和事件
- C# DES (ECB模式) 加密解密 --单倍长
- z铭 WPF bitmap转bitmapimage 使用 CreateBitmapSourceFromHBitmap内存泄漏
- C# 如何获取出错的错误所在行数信息[原创]_C#教程_脚本之家