LINQ和StreamReader的线条越来越 [英] Linq and streamreader getting lines

查看:114
本文介绍了LINQ和StreamReader的线条越来越的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用LINQ,什么是efficent方式来获得一个制表符分隔的.txt文件每个字符串(然后得到每个字,平时有什么string.Split(...)呢)?

Using LINQ, what is an efficent way to get each string from a tab-delimited .txt file (and then get each word, usually what string.Split(...) does)?

var v = from line in File.ReadAllLines()
   select n

这是解决方案,我相信的一部分。如果此使用收益回报,我不介意。

Is part of this solution I believe. I don't mind if this uses yield return.

编辑:我也看到了放在这里,详细说明正是我试图做的线程,但无法找到它们。

I've also seen threads on here detailing exactly what I am trying to do, but can't find them.

推荐答案

我不完全知道你是问什么,但它听起来就像你试图让每一个字从制表符分隔的文件作为的IEnumerable<串GT; 。如果是的话请尝试以下

I'm not entirely sure what you're asking but it sounds like you're trying to get every word from a tab delimited file as an IEnumerable<string>. If so then try the following

var query = File.ReadAllLines(somePathVariable)
                .SelectMany(x => x.Split(new char[] { '\t' });

这篇关于LINQ和StreamReader的线条越来越的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆