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)