C# csharp中的结构化数组? 我有下面的C++代码,我想把它翻译成C<< /p>

C# csharp中的结构化数组? 我有下面的C++代码,我想把它翻译成C<< /p>,c#,c++,C#,C++,但我一直停留在“元素”的定义上,它是一个结构化数组 最好用什么 var list = new List<KeyValuePair<string, int>>(); for (i = 0; i< 8; i++) { Ixx += Element[i].vLocalInertia.x + Element[i].fMass * (Element[i].vCGCoords.y*Element[i].vCGCoords.y + Element[i].vCGCoord

但我一直停留在“元素”的定义上,它是一个结构化数组

最好用什么

var list = new List<KeyValuePair<string, int>>();

for (i = 0; i< 8; i++)
{
    Ixx += Element[i].vLocalInertia.x + Element[i].fMass * (Element[i].vCGCoords.y*Element[i].vCGCoords.y + Element[i].vCGCoords.z*Element[i].vCGCoords.z);
    Iyy += Element[i].vLocalInertia.y + Element[i].fMass * (Element[i].vCGCoords.z*Element[i].vCGCoords.z + Element[i].vCGCoords.x*Element[i].vCGCoords.x);
    Izz += Element[i].vLocalInertia.z + Element[i].fMass * (Element[i].vCGCoords.x*Element[i].vCGCoords.x + Element[i].vCGCoords.y*Element[i].vCGCoords.y);
    Ixy += Element[i].fMass * (Element[i].vCGCoords.x * Element[i].vCGCoords.y);
    Ixz += Element[i].fMass * (Element[i].vCGCoords.x * Element[i].vCGCoords.z);
    Iyz += Element[i].fMass * (Element[i].vCGCoords.y * Element[i].vCGCoords.z);
}   
像这样的

 public struct Element
    {
        public struct coord
        {
            public int x;
            public int y;
            public int z;
        }

        public coord vLocalIntetia;
        public int fMass;
        public coord vCGCoords;

    }

    Element[] element = new Element[8];
编辑

或者这个(加上你的细节)


你对“结构化数组”有什么理解?似乎
元素
只是某个类的数组/向量。您可以在C#中执行完全相同的操作。什么是
元素
?如何申报?
list
与此有什么关系?你确定你所显示的代码是C++而不是C++吗?(C++没有关键字[Value> Value/COD>和<代码>列表< /C>)和 KealValuePaule<代码>看起来好像.NET类)对不起,这里是新手。我试图在游戏引擎(Unity)中使用此代码
 public struct Element
    {
        public struct coord
        {
            public int x;
            public int y;
            public int z;
        }

        public coord vLocalIntetia;
        public int fMass;
        public coord vCGCoords;

    }

    Element[] element = new Element[8];
 public struct BodyElement 
    {
        float   fMass;
        Vector  vDCoords;
        Vector  vCGCoords;
        Vector  vLocalInertia;
        float   fIncidence;
        float   fDihedral;
        Vector  vNormal;
        float   fArea;
        int     iFlap;
    }


    BodyElement[] element = new BodyElement[8];