从列表中获取特定值 [英] Getting a certain value from a list

查看:74
本文介绍了从列表中获取特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我需要从外部文本文件中读取列表中的第一个值。

I need to get the first value out of a list I'm reading from an external text file.

文件显示如下:

好的,魔术帮派

等...

我需要只需读取逗号前的值。

I need to just read the value before the comma.

任何帮助都将不胜感激。

Any help would be appreciated.

推荐答案

这是一种方法:

        ' file may have multiplr lines
        ' read all lines from it
        Dim allitems As List(Of String) = IO.File.ReadLines(path).ToList

        ' take first line and split at ","
        Dim items As String() = allitems(0).Split(","c)

        ' put desired item into variable
        Dim wanteditem As String = items(0)


这篇关于从列表中获取特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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