请教一下,byte* pData是什么意思

小菲1215 2011-06-09 02:00:30

请教一下这个方法unsafe public ushort GetCrcITU_T(byte * pData,int nLength,out string crcCode)
{}中byte * pData是什么意思,如何调用这个方法
...全文
622 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
garfieldzf 2011-06-09
  • 打赏
  • 举报
回复
byte指针。

ref byte PData
小菲1215 2011-06-09
  • 打赏
  • 举报
回复
哪位大哥指点一下,我该如何用GetCrcITU_T这个方法传递参数
小菲1215 2011-06-09
  • 打赏
  • 举报
回复
unsafe public ushort GetCrcITU_T(byte * pData,int nLength,out string crcCode)
{
ushort fcs=0xFFFF;
ushort uRlt;
string strTmp;
while(nLength>0)
{
fcs= (ushort) ((ushort)(fcs>>8)^ crctab16[(fcs ^ *pData) &0xFF ]);
nLength--;
pData++;
}

uRlt=(ushort)~fcs;
strTmp=uRlt.ToString("X4") ;
crcCode=strTmp.Substring(2,2) + " " + strTmp.Substring(0,2);

return uRlt;
}

unsafe public bool IsCrcITUGood_T(byte * pData,int nLength)
{
ushort fcs=0xFFFF;
while(nLength>0)
{
fcs= (ushort) ((ushort)(fcs>>8)^ crctab16[(fcs ^ *pData) &0xFF ]);
nLength--;
pData++;
}

return (fcs==0xF0B8);
}

}

 这个是我在网上找一个CRCITU格式的代码,我现在要把01 01 01 01 获取这个字符串的CRC检验码
ChrisAK 2011-06-09
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xiaobifei 的回复:]

为什么我使用
byte[] rby=strToToHexByte("01 01 01");
string crccode="";
GetCrcITU_T(&rby,rby.Length,out crccode);///这句会提 醒错误呢

unsafe public ushort GetCrcITU_T(byte * pData,int nLength,out string c……
[/Quote]数组作为一个引用类型,是取不到指针的.
另外如果这里是要求输入一个字节序列的话.
没必要声明成unsafe byte*
直接声明称byte[],.net interop会在实际调用的时候转成byte*
小菲1215 2011-06-09
  • 打赏
  • 举报
回复
unsafe public ushort GetCrcITU_T(byte* pData, int nLength, out string crcCode)
{
ushort fcs = 0xFFFF;
ushort uRlt;
string strTmp;
while (nLength > 0)
{
fcs = (ushort)((ushort)(fcs >> 8) ^ crctab16[(fcs ^ *pData) & 0xFF]);
nLength--;
pData++;
}

uRlt = (ushort)~fcs;
strTmp = uRlt.ToString("X4");
crcCode = strTmp.Substring(2, 2) + " " + strTmp.Substring(0, 2);

return uRlt;
}
小菲1215 2011-06-09
  • 打赏
  • 举报
回复
为什么我使用
byte[] rby=strToToHexByte("01 01 01");
string crccode="";
GetCrcITU_T(&rby,rby.Length,out crccode);///这句会提 醒错误呢

unsafe public ushort GetCrcITU_T(byte * pData,int nLength,out string crcCode)
flyerwing 2011-06-09
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
使用非安全代码,这样可以使用指针pData,就byte指针
[/Quote]
byte指针
kingdom_0 2011-06-09
  • 打赏
  • 举报
回复
C# 中在非安全代码中定义的指针,类型为byte型.
byte * pData;
bdmh 2011-06-09
  • 打赏
  • 举报
回复
使用非安全代码,这样可以使用指针pData,就byte指针

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧