我正在阅读文本文件并将其分隔为分隔点。在:之前的所有内容都是左边的值,之后的所有内容都是正确的。什么是通过线条的最佳循环,并将字符串值存储到2个列表中,左边还是右边?我不需要它们输出,只需将值存储在列表中。用于从文本文件存储值的循环帮助
namespace WindowsFormsApplication8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
id newId = new id();
newId.Left = "";
id newId2 = new id();
newId2.Right = "";
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.ShowDialog();
textBox1.Text = of.FileName;
using (StreamReader sr = new StreamReader(of.FileName));
string content = File.ReadAllText(of.FileName);
string[] split = content.Split(';' , ':');
foreach (string segment in split)
{
if
}
}
你的代码不完整,甚至没有编译。 – LawfulHacker
你是说文本文件中的每一行都有':'?你想分割每一行? –
@elgonzo不,这只是人们争论谁是对的,我甚至不会要求我的代码在我的工作上寻求方向,没有人会把我带到那里。 – user3617347