Repository navigation
OnixLabs.Core.ArrayExtensions
Extension methods for arrays, including generic-array copying and concatenation, and a byte[]-to-string conversion.
| Namespace | OnixLabs.Core |
| Assembly | OnixLabs.Core.dll (NuGet) |
| Inheritance |
object → ArrayExtensions
|
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ArrayExtensionsNote This class is decorated with
[EditorBrowsable(EditorBrowsableState.Never)], which keeps the container class itself out of IntelliSense lists while its extension methods remain fully usable on the receiver types. Bring the methods into scope withusing OnixLabs.Core;.
ArrayExtensions provides helpers that operate on generic T[] arrays and on byte[] specifically. The copy methods produce new arrays rather than mutating the receiver. Several of these methods use C# 14 extension blocks (extension(Receiver receiver) { ... }), so the receiver type appears in the block declaration rather than as a this parameter; the signatures shown below are the call-site signatures as consumed by user code.
| Method | Returns | Description |
|---|---|---|
Copy<T>() |
T[] |
Creates an exact copy of the current array. |
Copy<T>(int, int) |
T[] |
Creates a copy of a contiguous range of the current array. |
ConcatenateWith<T>(T[]) |
T[] |
Concatenates the current array with another array. |
ToString(Encoding) |
string |
Decodes the current byte[] to a string using the specified encoding. |
public T[] Copy<T>()Creates a copy of the current T array.
Returns — An exact copy of the current T array.
int[] source = [1, 2, 3];
int[] clone = source.Copy(); // [1, 2, 3] (new array)public T[] Copy<T>(int index, int count)Creates a copy of a contiguous range of the current T array.
| Parameter | Type | Description |
|---|---|---|
index |
int |
The index of the array to begin copying from. |
count |
int |
The number of elements of the array to copy. |
Returns — A new T array containing the specified range of elements from the current array.
Exceptions
| Exception | Condition |
|---|---|
ArgumentOutOfRangeException |
index and count fall outside the bounds of the array. |
int[] source = [10, 20, 30, 40, 50];
int[] middle = source.Copy(1, 3); // [20, 30, 40]public T[] ConcatenateWith<T>(T[] other)Concatenates the current T array with another T array.
| Parameter | Type | Description |
|---|---|---|
other |
T[] |
The other T array to concatenate with the current array. |
Returns — A new T array consisting of the current array followed by other.
byte[] head = [0x01, 0x02];
byte[] tail = [0x03, 0x04];
byte[] all = head.ConcatenateWith(tail); // [0x01, 0x02, 0x03, 0x04]public string ToString(Encoding encoding)Obtains the string representation of the current byte[] array, decoded with the specified encoding.
| Parameter | Type | Description |
|---|---|---|
encoding |
Encoding |
The Encoding used to convert the current byte[] into a string. |
Returns — The string representation of the current byte[] array.
byte[] bytes = [0x48, 0x65, 0x6C, 0x6C, 0x6F];
string text = bytes.ToString(Encoding.UTF8); // "Hello"- OnixLabs.Core
- Home
- OnixLabs.Core.DateTimeExtensions
- OnixLabs.Core.ComparableExtensions
- OnixLabs.Core.ISpanParsableExtensions
- OnixLabs.Core.ObjectExtensions
- OnixLabs.Core.RandomExtensions
- OnixLabs.Core.ReadOnlySequenceExtensions
- OnixLabs.Core.ReadOnlySpanExtensions
- OnixLabs.Core.StringExtensions
- OnixLabs.Core on NuGet
ONIXLabs .NET Library · Repository · NuGet · License (Apache-2.0)
Copyright © ONIXLabs 2020. Licensed under the Apache License, Version 2.0.
- Enumeration<T>
- Optional<T>
- OptionalEqualityComparer<T>
- OptionalExtensions
- Result
- Result<T>
- ResultEqualityComparer<T>
- ResultExtensions
- Specification<T>
- Preconditions
- IValueEquatable<T>
- IValueComparable<T>
- IBinaryConvertible
- ISpanBinaryConvertible
- IMemoryBinaryConvertible
- ArrayExtensions
- ComparableExtensions
- DateTimeExtensions
- ISpanParsableExtensions
- ObjectExtensions
- RandomExtensions
- ReadOnlySequenceExtensions
- ReadOnlySpanExtensions
- StringExtensions
- Base16
- Base32
- Base58
- Base64
- IBaseCodec
- IBaseValue
- IBaseValue<T>
- Base16Codec
- Base32Codec
- Base58Codec
- Base64Codec
- Base16FormatProvider
- Base32FormatProvider
- Base58FormatProvider
- Base64FormatProvider
- EncodingExtensions
- ReadOnlySpanExtensions
- StringBuilderExtensions
- BigDecimal
- BigDecimalEqualityComparer
- BigDecimalOrdinalityComparer
- NumberInfo
- NumberInfoEqualityComparer
- NumberInfoOrdinalityComparer
- Int256
- Int512
- UInt256
- UInt512
- Float128
- Float256
- GenericMath
- NumericsExtensions
- ConversionMode
- ScaleMode
- Hash
- NamedHash
- Sha3
- Sha3Hash224
- Sha3Hash256
- Sha3Hash384
- Sha3Hash512
- Sha3Shake128
- Sha3Shake256
- MerkleTree
- MerkleTree<T>
- PrivateKey
- PublicKey
- NamedPrivateKey
- NamedPublicKey
- EcdhPrivateKey
- EcdhPublicKey
- EcdsaPrivateKey
- EcdsaPublicKey
- EddsaPrivateKey
- EddsaPublicKey
- RsaPrivateKey
- RsaPublicKey
- DigitalSignature
- DigitalSignatureAndPublicKey
- Salt
- Secret
- ICryptoPrimitive<T>
- IHashable
- IEcdhPrivateKey
- IEcdsaPrivateKey
- IEddsaPrivateKey
- IRsaPrivateKey
- IPrivateKeyDerivable<T>
- IPrivateKeyExportable
- IPrivateKeyImportable<T>
- IPrivateKeyPemImportable<T>
- IPrivateKeyPkcs8Exportable
- IPrivateKeyPkcs8Importable<T>
- IPrivateKeyPkcs8PemExportable
- IPrivateKeyRawExportable
- IPrivateKeyRawImportable<T>
- IPrivateKeyRawPemExportable
- IEcdhPublicKey
- IEcdsaPublicKey
- IEddsaPublicKey
- IRsaPublicKey
- IPublicKeyExportable
- IPublicKeyImportable<T>
- IPublicKeyPemExportable
- IPublicKeyPemImportable<T>
- IPublicKeyRawExportable
- IPublicKeyRawImportable<T>
- HashAlgorithmExtensions
- ReadOnlySpanExtensions