Delphi-7将记录打包到C#结构中

时间:2016-02-17 15:04:22

标签: c# delphi struct delphi-7 record

我正在将Delphi程序转换为C#。有人告诉我基本上一行一行地转换。从来没有使用过Delphi,我想知道我将打包记录转换为C#结构是否正确?

的Delphi:

Type

  RPrec = packed record
     now: TDateTime;
     ShipLatitude: longint;
     ShipLatUncertainty: short;
     ShipAltitude: single;
     FishLatitude: longint;
     FishHeading: single;
     ContactID: longint;
     Range1: short;
    end;


    RPhdrec = packed record
     now: TDateTime;
     MinimumLatitude: longint;
     MinimumAltitude: single;
    end;

    Vehiclerec = packed record
       Latitude: longint;
       LonUncertainty: short;
       Altitude: single;
     end;

   VehiclerecPtr =  ^Vehiclerec; 

   RAMPrec2 = packed record
         now: TDateTime;
         Ship:Vehiclerec;
         DataAvailFlags: longint;
         Range2: short;
    end;

C#

        public struct RPrec
        {
            DateTime now;
            int ShipLatitude;
            short ShipLatUncertainty;
            float ShipAltitude;
            int FishLatitude;
            float FishHeading;
            short Range1;
        }

        public struct RPhdrec
        {
            DateTime now;
            int MinimumLatitude;
            float MinimumAltitude;
        }

        public struct Vehiclerec
        {
            int Latitude;
            short LonUncertainty;
            float Altitude;
        }

        public struct RAMPrec2
        {
            DateTime now;
            Vehiclerec Ship;
            int DataAvailFlags;
            short Range2;
        }

这看起来好吗?我已经看到过使用过我以前从未使用过的StructLayouts的人的例子,那会更好吗?

0 个答案:

没有答案