0
我,我會非常想表現爲這樣的數據:結構在C#和構造
LinkedList<T>[]
但是,你不能這樣做仿製藥,所以我把它包在一個結構:
public struct SuitList
{
LinkedList<T> aList;
public SuitList()
{
aList = new LinkedList<T>();
}
}
現在
,在我的課我有
SuitList[] myStructList; //there is only 4 indices of myStructList
如何初始化ALIST,我的構造函數的類裏面?我想這個如下:
myStructList = new SuitList[4];
for(int i = 0; i < 4; i++)
{
myStructList[i] = new SuitList();
}
編譯器給了我一個錯誤說的Structs不能包含明確的參數構造函數。有沒有更好的方法來做到這一點? 感謝您的幫助提前。
這聽起來像一個很奇怪的構造。你爲什麼想要一個鏈表? – SLaks 2012-02-05 23:38:55
當您嘗試使用「LinkedList []'時收到了什麼錯誤?它沒有什麼問題。 –
phoog
2012-02-05 23:44:50
@phoog,你是對的。我錯了 – CodeKingPlusPlus 2012-02-06 00:36:52