• 全部
...

如何从byte转换为intptr

putworld 2006-07-27 09:35:51
谢谢
...全文
给本帖投票
866 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
pclion 2006-07-28
  • 打赏
  • 举报
回复
Marshal.Copy:
public static void Copy(
byte[] source,
int startIndex,
IntPtr destination,
int length
);
Parameters
source
The one-dimensional array to copy from.
startIndex
The zero-based index into the array where Copy should start.
destination
The memory pointer to copy to.
length
The number of array elements to copy.


例子:
byte[] ba ={ 'a', 'b', 'c', 'd' };
IntPtr p = Marshal.AllocCoTaskMem(ba.Length);
Marshal.Copy(ba, 0, p, ba.Length);
真相重于对错 2006-07-28
  • 打赏
  • 举报
回复
System.IntPtr ptr = Marshal.AllocHGlobal(1);
Marshal.WriteByte(ptr, byte);
putworld 2006-07-28
  • 打赏
  • 举报
回复
是byte,不是byte[]
diandian82 2006-07-27
  • 打赏
  • 举报
回复
byte or byte[] ?

111,089

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
社区公告

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

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

手机看
关注公众号

关注公众号

客服 返回
顶部