偶在数组 playList中存放了播放列表,想通过按钮删除实现清空playList中的数据:
private void menuItemDelAll_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
for(int i = 0;i < playList.Length; i ++ )
playList[i] = '';
}
结果系统提示错误:“空字符”
!!>_<
请问应该怎样实现清空playList数组?
private void menuItemDelAll_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
for(int i = 0;i < playList.Length; i ++ )
playList[i] = '';
}
结果系统提示错误:“空字符”
!!>_<
请问应该怎样实现清空playList数组?
{
listBox1.Items.Clear();
playList.Clear();
}
^-^thanks ~~
调试发生错误: 重载“Clear”方法未获取“0”参数
??
{
listBox1.Items.Clear();
playList.Length = 0;
}
{
listBox1.Items.Clear();
playList = new string [0];
}
我想知道playList = new string [0];跟playList[i] = "";有区别吗?
在清除playList中的文件路径后,我得要把 songindex (songindex记录歌曲总数) 赋值为0.
偶分别用两种方法调试,结果用playList = new string [0]时出现错误,当清空后再重新添加文件时,出现错误:“索引超出了数组界限”
方法一:(失败~_~!)
private void menuItemDelAll_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
playList = new string [0];
songindex = 0;
}
方法二:(成功^_^~)
private void menuItemDelAll_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
for(int i = 0;i < playList.Length; i ++ )
playList[i] = "";
songindex = 0;
}
Array.Clear(playList)
上面有人说过了
第一次发帖就有那么多人回复~~感动、落泪
多谢了~~