怎么读出文件中所有Tab键后的元素? 比如某个文件中a 1b 2c 3怎么把1,2,3读出来? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 StreamReader read = new StreamReader(@"c:\1.txt");string s =string.Empty;string [] ss=null;while((s=read.ReadLine())!=null){ ss=s.Split(new char[]{'\t'}); foreach(string s1 in ss) { Console.WriteLine(s1); }} read.Close(); 楼上基本上是正解,只是要完全实现LZ 的需求需要改一下StreamReader read = new StreamReader(@"c:\1.txt"); string s =string.Empty; string [] ss=null; while((s=read.ReadLine())!=null) { ss=s.Split(new char[]{'\t'}); if(ss.Length==2) Console.WriteLine(ss[1]); else Continue;} 哦,刚才写错了,是ss.Length==3 参考代码:StreamReader sr = new StreamReader(sFileName,Encoding.Default);string[] strArray = null;string strRead = "";string strValue = "";if(sr==null) {return;}while(sr.Peek()>0){ strRead = sr.ReadLine(); if(string.IsNullOrEmpty(strRead)) {continue;} strArray = strRead.Split(' ');//' '单引号之间是Tab键 if(strArray == null || strArray.Length < 2) {continue;} strValue = strArray[1]; //strValue即为你需要读取的值}sr.Close(); 呃,其实我更想知道的是不针对于我举的例而是所有Tab后...a 1 55b 2 65c 3 67 一样,只要数据读出来了,然后就有tab来split就可以的 C# Winform VLC如何使用 截取字符长度 问题 得到程序句柄并向他发送ctrl+c问题 求code 93 extended码的条码字体 批量勾选后,然后批量数据库设置名称等字段,还提供用户自定义每条数据~~~如何实现 如何判断一个节点有无一个属性? 受不了啦 急求C#运算符r3 = (0x6c000 | ((DEN >> 12) & 0x3ff))指导 简单问题,急 调查一下,各位的开发项目中,有没有用到什么正版的,也就是向第三方买来的组件,什么类型的组件有市场??? winform 如何清空IE地址栏历史 一个关于Enum.Parse的列子不明白
string s =string.Empty;
string [] ss=null;
while((s=read.ReadLine())!=null)
{
ss=s.Split(new char[]{'\t'});
foreach(string s1 in ss)
{
Console.WriteLine(s1);
}}
read.Close();
StreamReader read = new StreamReader(@"c:\1.txt");
string s =string.Empty;
string [] ss=null;
while((s=read.ReadLine())!=null)
{
ss=s.Split(new char[]{'\t'});
if(ss.Length==2)
Console.WriteLine(ss[1]);
else
Continue;
}
StreamReader sr = new StreamReader(sFileName,Encoding.Default);
string[] strArray = null;
string strRead = "";
string strValue = "";
if(sr==null) {return;}
while(sr.Peek()>0)
{
strRead = sr.ReadLine();
if(string.IsNullOrEmpty(strRead)) {continue;}
strArray = strRead.Split(' ');//' '单引号之间是Tab键
if(strArray == null || strArray.Length < 2) {continue;}
strValue = strArray[1]; //strValue即为你需要读取的值
}
sr.Close();
而是所有Tab后...
a 1 55
b 2 65
c 3 67