daniel : dawson
jack : miller
frozen : mass
ralph : dcosta
我想在TextBox2中冒号其中ListBox1中含有丹尼尔和listbox2后显示在ListBox1中和文本冒号前的文本字符的文本文件包含道森。代码到目前为止,
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Text Files|*.txt";
openFileDialog1.Title = "Select a Text file";
openFileDialog1.FileName = "";
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
string file = openFileDialog1.FileName;
StreamReader reader = new StreamReader(file);
List<string> users = new List<string>();
while (!reader.EndOfStream)
{
string line = reader.ReadLine();
string[] tokens = line.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in tokens)
{
if (true)
{
listBox3.Items.Add(s) ;
}
listBox4.Items.Add(s);
}
}
}
和上面代码的输出是:
Lisbox1 Lisbox2
daniel daniel
dawson dawson
jack jack
miller miller
,而我工作的
listbox1 listbox2
daniel dawson
jack miller
任何帮助将不胜感激,谢谢
ot'if(true)'是什么意思? –