2013-12-17 49 views
2

我有串600线,全部被编号例如:只显示2用户输入号码之间的字串值

contents[0] = "HALTUNG;" + textBox2.Text + "-01" + " " + textBox2.Text + "-02;" + textBox2.Text + "-01;" + textBox2.Text + "-02"; 
contents[1] = "HALTUNG;" + textBox2.Text + "-02" + " " + textBox2.Text + "-03;" + textBox2.Text + "-02;" + textBox2.Text + "-03"; 
contents[2] = "HALTUNG;" + textBox2.Text + "-03" + " " + textBox2.Text + "-04;" + textBox2.Text + "-03;" + textBox2.Text + "-04"; 
contents[3] = "HALTUNG;" + textBox2.Text + "-04" + " " + textBox2.Text + "-05;" + textBox2.Text + "-04;" + textBox2.Text + "-05"; 
contents[4] = "HALTUNG;" + textBox2.Text + "-05" + " " + textBox2.Text + "-06;" + textBox2.Text + "-05;" + textBox2.Text + "-06"; 
contents[5] = "HALTUNG;" + textBox2.Text + "-06" + " " + textBox2.Text + "-07;" + textBox2.Text + "-06;" + textBox2.Text + "-07"; 

我想写入文件2用户输入号码前的字符串:(2- 8)或(1-250) 我该怎么办?

感谢

+1

我还没有丝毫的线索想要什么...你想写一些用户输入值之间的arrayElements? – Vogel612

+5

请告诉我你没有输入600个字符串作业? – DGibbs

+0

通过代码行获得付款? –

回答

1

您可以使用LINQ SkipTake方法,我assum开始已经开始行号和结束已结束的行号。

var lines = contents.Skip(Start).Take(End-Start); 
+0

这就是我正在寻找的灵感,谢谢! – user3110431

相关问题