非常简单的 C# CSV 阅读器 [英] Very simple C# CSV reader
本文介绍了非常简单的 C# CSV 阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从 CSV 文件创建一个数组.
I'd like to create an array from a CSV file.
这就像您想象的一样简单,CSV 文件永远只有一行和这些值:
This is about as simple as you can imagine, the CSV file will only ever have one line and these values:
Device, SignalStrength, Location, Time, Age.
我想将这些值放入一维数组中.
I'd like to put these values into one dimensional array.
我尝试了一些示例,但它们都比要求的复杂.
I've tried some examples but they've all been more complicated than required.
推荐答案
如果只有一行,请执行以下操作:
If there is only ever one line then do something like this:
using System;
using System.IO;
class Program
{
static void Main()
{
String[] values = File.ReadAllText(@"d: est.csv").Split(',');
}
}
这篇关于非常简单的 C# CSV 阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文