Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Delphi中创建和访问多维数组的记录成员(从C#struct转换而来)?_Delphi_Multidimensional Array_Struct_Record_Pascal - Fatal编程技术网

如何在Delphi中创建和访问多维数组的记录成员(从C#struct转换而来)?

如何在Delphi中创建和访问多维数组的记录成员(从C#struct转换而来)?,delphi,multidimensional-array,struct,record,pascal,Delphi,Multidimensional Array,Struct,Record,Pascal,C#中的我的结构: 现在我在Delphi中将结构声明为记录,如下所示: type AlignEx = (left, middle, right); type myStruct = record index: Integer; alignment: AlignEx ; end; 现在我无法获得像C#onemyStruct[,]这样的以逗号分隔的结构数组 我如何实现这一点 谢谢以下是如何做到这一点: type TAlignEx =

C#中的我的结构:

现在我在Delphi中将结构声明为记录,如下所示:

 type
    AlignEx = (left, middle, right);

  type
    myStruct = record
      index: Integer;
      alignment: AlignEx ;

    end;
现在我无法获得像C#one
myStruct[,]这样的以逗号分隔的结构数组

我如何实现这一点

谢谢以下是如何做到这一点:

type
    TAlignEx = (aeLeft, aeMiddle, aeRight);

    TMyStruct = record
      Index     : Integer;
      Alignment : TAlignEx;
    end;

const
    MyStructArray : array [0..2, 0..1] of TMyStruct =
        (((Index: 1; Alignment: aeLeft),
          (Index: 2; Alignment: aeLeft)),

         ((Index: 3; Alignment: aeMiddle),
          (Index: 4; Alignment: aeMiddle)),

         ((Index: 5; Alignment: aeRight),
          (Index: 6; Alignment: aeRight)));

我使用了一种在Delphi中更常见的命名约定。通常,遵循通常的命名约定是一个好主意,但当然,您可以自由使用您最喜欢的任何东西。

这是否回答了您的问题?
type
    TAlignEx = (aeLeft, aeMiddle, aeRight);

    TMyStruct = record
      Index     : Integer;
      Alignment : TAlignEx;
    end;

const
    MyStructArray : array [0..2, 0..1] of TMyStruct =
        (((Index: 1; Alignment: aeLeft),
          (Index: 2; Alignment: aeLeft)),

         ((Index: 3; Alignment: aeMiddle),
          (Index: 4; Alignment: aeMiddle)),

         ((Index: 5; Alignment: aeRight),
          (Index: 6; Alignment: aeRight)));