Delphi中的 type PDevice_Set = ^TDevice_Set (注:TDevice_Set为结构)上述Delphi中的这行代码如何转换成C#语言的相应代码,谢谢

解决方案 »

  1.   

    定义了一个指针类型,用IntPtr代替就可以。
      

  2.   

    定义了一个指针类型,用IntPtr代替就可以不会用,请问怎么代替呢?谢谢
      

  3.   

    你连TDevice_Set的定义都不给啊,需要在C#里面给一个等效的TDevice_Set定义,这样就可以直接声明了。
      

  4.   

    type TDevice_set = record
      id          : Integer;
      _name       : Array[0..31] of Char;
      username    : Array[0..31] of Char;
      userpass    : Array[0..15] of Char;
      ip          : Array[0..15] of Char;
      port        : Cardinal;
      channel_count : Byte;
      start_channel : Byte;
      device_type   : Byte;
    end;
      

  5.   

    Cardinal:delphi中代表无符号整型(貌似是32位无符号的)
      

  6.   

    1.定义结构体
    [System.Runtime.InteropServices.StructLayout
            (LayoutKind.Explicit)]  
    public struct TDevice_set
    {
       [System.Runtime.InteropServices.FieldOffset(0)]
       public int32 id;   [System.Runtime.InteropServices.FieldOffset(4)]
        unsafe public fixed byte_name[32];   System.Runtime.InteropServices.FieldOffset(36)]
       unsafe public fixed byte username [32];  System.Runtime.InteropServices.FieldOffset(48)]
       unsafe public fixed byte userpass[16];   System.Runtime.InteropServices.FieldOffset(64)]
       unsafe public fixed byte ip[16];   [System.Runtime.InteropServices.FieldOffset(80)]
       public uint32 port;   [System.Runtime.InteropServices.FieldOffset(84)]
       public byte channel_count;   ......省略了
    }2.PDevice_Set = ^TDevice_Set 在c#中你不需要定义了直接使用TDevice_set* 来定义变量,记得项目中药运行不安全代码
      

  7.   

    type TDevice_set = record
      id          : Integer;
      _name       : Array[0..31] of Char;
      username    : Array[0..31] of Char;
      userpass    : Array[0..15] of Char;
      ip          : Array[0..15] of Char;
      port        : Cardinal;
      channel_count : Byte;
      start_channel : Byte;
      device_type   : Byte;
    end;
    type PDevice_Set = ^TDevice_Set;function Devicelist_Callback(aset: PDevice_set;pksize:integer): Boolean;
    var
      device : PDevice_Set;
    begin
      new(device);
      if  sizeof(TDevice_set)<pksize then
         pksize := sizeof(TDevice_set);
      move(aset^, device^, sizeof(TDevice_set));
      devicelist.Add(device);
      result := True;
    end;如何把上述代码翻译成对应的C#代码
      

  8.   

    to 4L 结构体不是值类型吗