Concat

Purpose

Sometimes it is necessary to concatenate data together to form an input or output. This is represented via the || symbol in pseudocode.

For example, an AEAD ciphertext is usually a ciphertext concatenated with a tag.

triangle-exclamation

Usage

Concat

Fills a span with the concatenation of two spans.

Spans.Concat(Span<byte> buffer, ReadOnlySpan<byte> a, ReadOnlySpan<byte> b)

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

buffer has a length not equal to a.Length + b.Length.

ArgumentOutOfRangeExceptionarrow-up-right

a has a length not equal to buffer.Length - b.Length.

ArgumentOutOfRangeExceptionarrow-up-right

b has a length not equal to buffer.Length - a.Length.

Concat

Fills a span with the concatenation of three spans.

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

buffer has a length not equal to a.Length + b.Length + c.Length.

ArgumentOutOfRangeExceptionarrow-up-right

a has a length not equal to buffer.Length - b.Length - c.Length.

ArgumentOutOfRangeExceptionarrow-up-right

b has a length not equal to buffer.Length - a.Length - c.Length.

ArgumentOutOfRangeExceptionarrow-up-right

c has a length not equal to buffer.Length - a.Length - b.Length.

Concat

Fills a span with the concatenation of four spans.

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

buffer has a length not equal to a.Length + b.Length + c.Length + d.Length.

ArgumentOutOfRangeExceptionarrow-up-right

a has a length not equal to buffer.Length - b.Length - c.Length - d.Length.

ArgumentOutOfRangeExceptionarrow-up-right

b has a length not equal to buffer.Length - a.Length - c.Length - d.Length.

ArgumentOutOfRangeExceptionarrow-up-right

c has a length not equal to buffer.Length - a.Length - b.Length - d.Length.

ArgumentOutOfRangeExceptionarrow-up-right

d has a length not equal to buffer.Length - a.Length - b.Length - c.Length.

Concat

Fills a span with the concatenation of five spans.

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

buffer has a length not equal to a.Length + b.Length + c.Length + d.Length + e.Length.

ArgumentOutOfRangeExceptionarrow-up-right

a has a length not equal to buffer.Length - b.Length - c.Length - d.Length - e.Length.

ArgumentOutOfRangeExceptionarrow-up-right

b has a length not equal to buffer.Length - a.Length - c.Length - d.Length - e.Length.

ArgumentOutOfRangeExceptionarrow-up-right

c has a length not equal to buffer.Length - a.Length - b.Length - d.Length - e.Length.

ArgumentOutOfRangeExceptionarrow-up-right

d has a length not equal to buffer.Length - a.Length - b.Length - c.Length - e.Length.

ArgumentOutOfRangeExceptionarrow-up-right

e has a length not equal to buffer.Length - a.Length - b.Length - c.Length - d.Length.

Concat

Fills a span with the concatenation of six spans.

Exceptions

ArgumentOutOfRangeExceptionarrow-up-right

buffer has a length not equal to a.Length + b.Length + c.Length + d.Length + e.Length + f.Length.

ArgumentOutOfRangeExceptionarrow-up-right

a has a length not equal to buffer.Length - b.Length - c.Length - d.Length - e.Length - f.Length.

ArgumentOutOfRangeExceptionarrow-up-right

b has a length not equal to buffer.Length - a.Length - c.Length - d.Length - e.Length - f.Length.

ArgumentOutOfRangeExceptionarrow-up-right

c has a length not equal to buffer.Length - a.Length - b.Length - d.Length - e.Length - f.Length.

ArgumentOutOfRangeExceptionarrow-up-right

d has a length not equal to buffer.Length - a.Length - b.Length - c.Length - e.Length - f.Length.

ArgumentOutOfRangeExceptionarrow-up-right

e has a length not equal to buffer.Length - a.Length - b.Length - c.Length - d.Length - f.Length.

ArgumentOutOfRangeExceptionarrow-up-right

f has a length not equal to buffer.Length - a.Length - b.Length - c.Length - d.Length - e.Length.

Notes

circle-info

There is unfortunately no Concat() function for arrays or spans in .NET, and there is not even a Span<T>.CopyTo(Span<T> destination, int index). This class fills that gap.

Last updated