尝试在列表框中打印歌曲叮咬。我尝试将它们添加为项目,但这只是打印windowsform1.cs。我是否必须转换项目,或者它是列表框打印字符串和int所需的函数。
private string title;
private string album, title, artist, genre;
private int length;
private void List_Click(object sender, EventArgs e)
{
MDB.listAllSongs(listBox1.Items);
}
public void listAllSongs(IList list)
{
List<Song> allSongs = new List<Song>();
foreach (Album album in albums)
{
album.listSongs(allSongs);
}
foreach (Song song in allSongs)
{
list.Add(song.ToString());
}
}
public void listSongs(List<Song> list)
{
foreach (Song song in songs)
{
list.Add(song);
}
}
答案 0 :(得分:1)
你需要在Song类中实现toString()方法,以返回你歌曲的标题:
public string toString()
{
return title;
}