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>)和 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];