.net - C# 结构体中的数组

标签 .net visual-studio c#-4.0

我在 C# 中遇到数组问题。我对 C# 很陌生,我习惯用 java 编写程序。 我正在尝试将此代码从 C++ 转移到 C#。 这是 C++ 代码

typedef struct point_3d {           // Structure for a 3-dimensional point (NEW)
    double x, y, z;
} POINT_3D;

typedef struct bpatch {             // Structure for a 3rd degree bezier patch (NEW)
    POINT_3D    anchors[4][4];          // 4x4 grid of anchor points
    GLuint      dlBPatch;               // Display List for Bezier Patch
    GLuint      texture;                // Texture for the patch
} BEZIER_PATCH;

我在 C# 中有 struct Vector3,它是 float x,y,z (我不需要 double ...) 现在我正在尝试制作结构 bpatch,但我在数组声明方面遇到问题

[StructLayout(LayoutKind.Sequential)]
struct BPatch
{
  Vector3[][] anchors = new Vector3[4][4]; //there is the problem
  uint dblPatch; // I'll probably have to change this two lines but it doesn't matter now
  uint texture; 

}

我做错了什么?我需要结构体中的aray 4x4,其类型应该是结构体Vector3,其声明为float x,float y,float z。 谢谢

最佳答案

您可以使用:

Vector3[,] anchors = new Vector3[4,4];

关于.net - C# 结构体中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8689044/

相关文章:

.net - Windows Phone 8 使用 RestSharp 请求启用 REST 的 https 托管服务

c# - 赢 C# : Run app as administrator without UAC prompt

asp.net-mvc-3 - [显示(提示MVC3

sql-server - 创建临时表并同时存储执行命令的结果

asp.net - C# 中的嵌套重复器

c# - session变量赋值给数据表和创建对象引用问题?

c# - 与 C# 中的 block 等效?

visual-studio - Visual Studio 2008 和 2013 之间的浮点不匹配

C# 查看特定 .NET 类的源代码

c++ - 每次成功编译后运行单元测试