此代码如何能够编译并运行无错误?可以通过公共属性设置私有变量的值,无需设置器
private void queueToolStripMenuItem_Click(object sender, EventArgs e)
{
//Class name MDPlayer
Playlist.QueueList.Add(tempPlayList[songView.SelectedIndex]);
Playlist.GetQueue = null;
QueueCombobox.Items.Clear();
foreach (PlayListData pld in Playlist.QueueList)
{
QueueCombobox.Items.Add(pld.Track);
}
}
class Playlist
{
private static List<PlayListData> queueList = new List<PlayListData>();
public static List<PlayListData> QueueList
{
get { return queueList;}
}
}
我怎么能够通过公共属性QueueList添加到queueList,甚至没有setter?
属性获取返回的对象,而不是类。同样,setter访问器也只能用于对象,而不是类。 –