很简单的C#的CSV读者 [英] Very simple C# CSV reader

查看:123
本文介绍了很简单的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:\test.csv").Split(',');
    }
}

这篇关于很简单的C#的CSV读者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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