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

查看:216
本文介绍了非常简单的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天全站免登陆