我正在制作一个Windows Phone 7应用程序,我放入一个滑块.它从1开始,到80结束.我想这样,当你停止滑块时,它会显示滑块位于文本块中的任何位置.(如果有人中途停止,一个文本块会说40)
让我们说那是文件中的文字.它会删除冒号,并将每个单词放入数组中自己的字符串中.例如:
exampleArray[0] = 'hello'
exampleArray[1] = 'my'
exampleArray[2] = 'name'
exampleArray[3] = 'is'
exampleArray[4] = 'lavi'
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
private void button2_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Text Files|*.txt";
DialogResult result = ofd.ShowDialog();
if(result == DialogResult.OK)
{
StreamReader textfile = new StreamReader(ofd.FileName);
string s = textfile.ReadToEnd();
string[] split = s.Split(':', '\n');
foreach (string word in split)
textBox1.Text = word[0].ToString();
//listBox1.Items.Add(word);
ofd.Dispose();
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
编辑:我想说的是如何制作它,以便每个单词存储在一个数组中,以便稍后用[0],[1],[2]等访问它?如果Split自动执行此操作,如何访问每个单词?