我正在從Windows窗體應用程序導航到Windows應用商店。我從網上獲得的課程如下所示,什麼是Windows 8商店應用程序中的c#CollectionBase的替換?
public class ElementList : CollectionBase
{
/// <summary>
/// A Collection of Element Nodes
/// </summary>
public ElementList()
{
}
public void Add(Node e)
{
// can't add a empty node, so return immediately
// Some people tried dthis which caused an error
if (e == null)
return;
this.List.Add(e);
}
// Method implementation from the CollectionBase class
public void Remove(int index)
{
if (index > Count - 1 || index < 0)
{
// Handle the error that occurs if the valid page index is
// not supplied.
// This exception will be written to the calling function
throw new Exception("Index out of bounds");
}
List.RemoveAt(index);
}
public void Remove(Element e)
{
List.Remove(e);
}
public Element Item(int index)
{
return (Element) this.List[index];
}
}
在上面的類中,商店應用程序不接受CollectionBase。請告訴我一種將其導航到Windows 8商店應用程序的方法。 。 。
在此先感謝!
感謝您的答覆。在上面的代碼中,他們使用了List.Add(),我們如何通過使用System.Collections.ObjectModel或System.Collections.Generic來實現。 。 。 – ggsmartboy