c# 从地址拷贝byte_如何使用指针复制字节数组 - C# 编程指南 | Microsoft Docs

如何使用指针复制字节数组(C# 编程指南)How to use pointers to copy an array of bytes (C# Programming Guide)

04/20/2018

本文内容

下面的示例使用指针将字节从一个数组复制到另一个数组。The following example uses pointers to copy bytes from one array to another.

此示例使用 unsafe 关键字,使你可以在 Copy 方法中使用指针。This example uses the unsafe keyword, which enables you to use pointers in the Copy method. fixed 语句用于声明指向源数组和目标数组的指针。The fixed statement is used to declare pointers to the source and destination arrays. fixed 语句将源数组和目标数组的位置固定在内存中,以便它们不会被垃圾回收所移动。The fixed statement pins the location of the source and destination arrays in memory so that they will not be moved by garbage collection. 当完成 fixed 块后,将取消固定数组的内存块。The memory blocks for the arrays are unpinned when the fixed block is completed. 因为此示例中的 Copy 方法使用 unsafe 关键字,所以必须使用 -unsafe 编译器选项对其进行编译。Because the Copy method in this example uses the unsafe keyword, it must be compiled with the -unsafe compile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值