Edit

Share via


Unsafe.CopyBlockUnaligned Method

Definition

Overloads

CopyBlockUnaligned(Byte, Byte, UInt32)

Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.

CopyBlockUnaligned(Void*, Void*, UInt32)

Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.

CopyBlockUnaligned(Byte, Byte, UInt32)

Source:
Unsafe.cs
Source:
Unsafe.cs
Source:
Unsafe.cs

Important

This API is not CLS-compliant.

Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.

C#
[System.CLSCompliant(false)]
public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount);
C#
public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount);

Parameters

destination
Byte

The managed pointer corresponding to the destination address to copy to.

source
Byte

The managed pointer corresponding to the source address to copy from.

byteCount
UInt32

The number of bytes to copy.

Attributes

Remarks

This API corresponds to the unaligned.1 cpblk opcode sequence. No alignment assumptions are made about the destination or source pointers. See ECMA-335, Sec. III.3.30 ("cpblk - copy data from memory to memory") and Sec. III.2.5 ("unaligned. (prefix) - pointer instruction might be unaligned") for more information.

Caution

This API is not intended for copying arbitrary-length runs of memory. Consider instead using MemoryCopy or CopyTo for this scenario.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6 (package-provided), 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided)

CopyBlockUnaligned(Void*, Void*, UInt32)

Source:
Unsafe.cs
Source:
Unsafe.cs
Source:
Unsafe.cs

Important

This API is not CLS-compliant.

Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses.

C#
[System.CLSCompliant(false)]
public static void CopyBlockUnaligned(void* destination, void* source, uint byteCount);
C#
public static void CopyBlockUnaligned(void* destination, void* source, uint byteCount);

Parameters

destination
Void*

The unmanaged pointer corresponding to the destination address to copy to.

source
Void*

The unmanaged pointer corresponding to the source address to copy from.

byteCount
UInt32

The number of bytes to copy.

Attributes

Remarks

This API corresponds to the unaligned.1 cpblk opcode sequence. No alignment assumptions are made about the destination or source pointers. See ECMA-335, Sec. III.3.30 ("cpblk - copy data from memory to memory") and Sec. III.2.5 ("unaligned. (prefix) - pointer instruction might be unaligned") for more information.

Caution

This API is not intended for copying arbitrary-length runs of memory. Consider instead using MemoryCopy or CopyTo for this scenario.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6 (package-provided), 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided)