小编Mic*_*vin的帖子

C#:通过TextReader的ReadLine()解析带有一个分隔符的字符串的有效方法是什么?

C#:对于TextReader的每个ReadLine(),用一个分隔符解析字符串有什么有效的方法?

我的目标是将ListView的代理列表加载到从.txt文件读取的两列(代理|端口)中.我如何继续使用分隔符":"将每个readline()拆分为代理和端口变量?

这是我到目前为止所得到的,

    public void loadProxies(string FilePath)
    {
        string Proxy; // example/temporary place holders
        int Port; // updated at each readline() loop.

        using (TextReader textReader = new StreamReader(FilePath))
        {
            string Line;
            while ((Line = textReader.ReadLine()) != null)
            {
                // How would I go about directing which string to return whether
                // what's to the left of the delimiter : or to the right?
                //Proxy = Line.Split(':');
                //Port = Line.Split(':');

                // listview stuff done here (this part I'm familiar with already) …
Run Code Online (Sandbox Code Playgroud)

c# listview split

5
推荐指数
1
解决办法
1651
查看次数

标签 统计

c# ×1

listview ×1

split ×1