我想創建一個generic list對PointF
對象的引用。 (不,我不希望創造PointF
對象的泛型列表。)但是,下面的行編譯失敗:C++/CLI:拳擊和通用列表
Generic::List<PointF^> ^pointList; // Generates error C3225
在另一方面,創造PointF
引用數組工作沒有問題如下:
array<PointF^> ^points = gcnew array<PointF^>;
下面是一個簡單的程序:
using namespace System;
using namespace System::Drawing;
namespace Generic = System::Collections::Generic;
int main(array<System::String ^> ^args)
{
array<PointF^> ^points = gcnew array<PointF^>{
nullptr, PointF(0.0f, 0.0f), PointF(1.0f, 0.0f), nullptr
};
Generic::List<PointF^> ^pointList;
Console::WriteLine(L"Hello World");
return 0;
}
如何創建的PointF
引用泛型列表?換句話說,我該如何創建盒裝PointF
的通用列表?
爲什麼它然後該數組編譯沒有問題?在這種情況下,編譯器會自動處理裝箱/拆箱。爲什麼在通用列表的情況下它不起作用? –
2009-10-13 08:33:37