这就是我所拥有的:
List<object[]> markers = new List<object[]>();
object[] marker = new object[2];
marker[0] = new Vector2(1, 2);
marker[1] = new Vector4(1, 2, 3, 4);
markers.Add(marker);
foreach (var item in markers)
{
int x = (Vector2)item[0].X; // Error: 'object' does not contain a definition
// for 'X' and no extension method 'X' accepting
// a first argument of type 'object' could be
// found (are you missing a using directive or
// an assembly reference?)
// other stuff
}
有没有办法在不失去代码可读性的情况下完成这项工作,或者我应该尝试使用类而不是对象数组?