+ -
当前位置:首页 → 问答吧 → delphi中的数据结构转换成C#怎么写?

delphi中的数据结构转换成C#怎么写?

时间:2011-10-29

来源:互联网

DevStruct =record
  nDevID : UINT8;
  nDevKind : UINT8;
  nCOMPORT : UINT8;
  nCOMBandRate : UINT8;
  nUSBDevFlag : UINT8;
  devIP : array[0..3] of UINT8;  
  IsTCP : BOOL;
  TCP_UDPPort : UINT32;
  end;
  pDevStruct =^DevStruct;

这样写对么?

public struct DevStruct
  {
  public byte nDevID;
  public byte nDevKind;
  public Byte nCOMPORT;
  public Byte nCOMBandRate;
  public Byte nUSBDevFlag;
  public Byte[] devIP;
  public Boolean IsTCP;  
  public Int32 TCP_UDPPort; 
  }

作者: wadyloo   发布时间: 2011-10-29

不知C#为何物

作者: qianchuan2010   发布时间: 2011-10-29

在C#里面测试一下你转化的这串代码是否能达到要求就知道行不行了;按照类型转换这样是可以.

作者: Robin95314852   发布时间: 2011-10-29

pdev.nDevID = 255;
  pdev.nDevKind = 2;
   

  pdev.devIP = new byte[4];
  pdev.devIP[0] = 192;
  pdev.devIP[1] = 168;
  pdev.devIP[2] = 0;
  pdev.devIP[3] = 10;
  pdev.IsTCP = false;
  pdev.TCP_UDPPort = 8000;
  state = uFuncXClass.Units.uFuncXClass.CmdOpenDevice(pdev);

这个总是返回0,我怀疑转换有问题

作者: wadyloo   发布时间: 2011-10-29

别人转到C#后苦不堪言,你却自投罗网...猪脑

作者: xonln   发布时间: 2011-10-29