Repository navigation
OnixLabs.Core.ISpanParsableExtensions
Extension methods for ISpanParsable<TSelf> types, providing a throwing parse helper.
| Namespace | OnixLabs.Core |
| Assembly | OnixLabs.Core.dll (NuGet) |
| Inheritance |
object → ISpanParsableExtensions
|
[EditorBrowsable(EditorBrowsableState.Never)]
public static class ISpanParsableExtensionsNote 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;.
ISpanParsableExtensions exposes a ParseOrThrow static helper directly on the type T (via the generic constraint where T : ISpanParsable<T>), offering a concise parse-or-throw pattern without requiring a separate try/catch block.
| Method | Returns | Description |
|---|---|---|
ParseOrThrow<T>(ReadOnlySpan<char>, IFormatProvider?) |
T |
Parses the specified value, or throws a FormatException if it cannot be parsed. |
public static T ParseOrThrow<T>(ReadOnlySpan<char> value, IFormatProvider? provider = null)
where T : ISpanParsable<T>Tries to parse the specified value using T.TryParse, or throws a FormatException if the value cannot be parsed. This is a static member exposed on the type T itself.
| Parameter | Type | Description |
|---|---|---|
value |
ReadOnlySpan<char> |
The value to parse. |
provider |
IFormatProvider? |
An object that provides culture-specific formatting information about the value. Defaults to null. |
Returns — A new instance of T parsed from the specified value.
Exceptions
| Exception | Condition |
|---|---|
FormatException |
The value cannot be parsed. |
int number = int.ParseOrThrow("123"); // 123
Guid id = Guid.ParseOrThrow("00000000-0000-0000-0000-000000000000");- OnixLabs.Core
- Home
- OnixLabs.Core.ArrayExtensions
- OnixLabs.Core.DateTimeExtensions
- OnixLabs.Core.ComparableExtensions
- 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