CryptographicOperations.ZeroMemory(Span<Byte>) Method

Definition

Fills the provided buffer with zeros.

C#
public static void ZeroMemory(Span<byte> buffer);

Parameters

buffer
Span<Byte>

The buffer to fill with zeros.

Remarks

This method exists to future-proof against potential optimizations in the .NET runtime that could eliminate memory writes that aren't followed by memory reads. While the C and C++ compilers have similar optimizations, no such optimizations are planned at this time for .NET.

Applies to

Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.1