SafeBuffer.Initialize Method

Definition

Specifies the size of the memory buffer to allocate. You must call this method before you use the SafeBuffer instance.

Overloads

Initialize(UInt64)

Defines the allocation size of the memory region in bytes. You must call this method before you use the SafeBuffer instance.

Initialize(UInt32, UInt32)

Specifies the allocation size of the memory buffer by using the specified number of elements and element size. You must call this method before you use the SafeBuffer instance.

Initialize<T>(UInt32)

Defines the allocation size of the memory region by specifying the number of value types. You must call this method before you use the SafeBuffer instance.

Initialize(UInt64)

Source:
SafeBuffer.cs
Source:
SafeBuffer.cs
Source:
SafeBuffer.cs

Important

This API is not CLS-compliant.

Defines the allocation size of the memory region in bytes. You must call this method before you use the SafeBuffer instance.

C#
[System.CLSCompliant(false)]
public void Initialize(ulong numBytes);

Parameters

numBytes
UInt64

The number of bytes in the buffer.

Attributes

Exceptions

numBytes is less than zero.

-or-

numBytes is greater than the available address space.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Initialize(UInt32, UInt32)

Source:
SafeBuffer.cs
Source:
SafeBuffer.cs
Source:
SafeBuffer.cs

Important

This API is not CLS-compliant.

Specifies the allocation size of the memory buffer by using the specified number of elements and element size. You must call this method before you use the SafeBuffer instance.

C#
[System.CLSCompliant(false)]
public void Initialize(uint numElements, uint sizeOfEachElement);

Parameters

numElements
UInt32

The number of elements in the buffer.

sizeOfEachElement
UInt32

The size of each element in the buffer.

Attributes

Exceptions

numElements is less than zero.

-or-

sizeOfEachElement is less than zero.

-or-

numElements multiplied by sizeOfEachElement is greater than the available address space.

Remarks

This method defines the required size of the memory region as the number of elements in an array multiplied by the size of each element.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Initialize<T>(UInt32)

Source:
SafeBuffer.cs
Source:
SafeBuffer.cs
Source:
SafeBuffer.cs

Important

This API is not CLS-compliant.

Defines the allocation size of the memory region by specifying the number of value types. You must call this method before you use the SafeBuffer instance.

C#
[System.CLSCompliant(false)]
public void Initialize<T>(uint numElements) where T : struct;

Type Parameters

T

The value type to allocate memory for.

Parameters

numElements
UInt32

The number of elements of the value type to allocate memory for.

Attributes

Exceptions

numElements is less than zero.

-or-

numElements multiplied by the size of each element is greater than the available address space.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0