0

我在 C# 中的结构:

  private enum AlignEx
        {
            left,
            middle,
            right
        }
           
   private struct myStruct
        {
            public int index;
            public AlignEx alignment;
        }


private myStruct[,] ....... {

}

现在我在 Delphi 中将 Structure 声明为 Record,如下所示:

 type
    AlignEx = (left, middle, right);

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

    end;

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

我该如何实施?

谢谢<3

4

1 回答 1

1

这是如何做到的:

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 中更常见的命名约定。遵循通常的命名约定通常是一个好主意,但当然你可以自由使用你最喜欢的任何东西。

于 2021-05-08T12:32:27.283 回答