Class StringExtensionMethods
- Namespace
- SodaFlow.Functional
- Assembly
- SodaFlow.Functional.dll
The parsing operations on a string which answer with a Maybe<T>.
[PublicAPI]
public static class StringExtensionMethods
- Inheritance
-
StringExtensionMethods
- Inherited Members
Remarks
Each of these wraps the framework's own TryParse for the type it
names, so what counts as parseable is what that method accepts. What
changes is the shape of the answer.
It is a Maybe<T> that code can map, filter, and put
together. It replaces a bool with an output parameter that
no code can read until the bool.
The overloads with no IFormatProvider parameter use the
current culture, again to agree with the method below it. Give
InvariantCulture explicitly for text which is
not meant to follow the user's culture - a configuration file, a
transmission format, or a machine-written record.
A null string parses as no value in each member here,
because that is what each framework TryParse does with one.
Methods
- TryParseBoolean(string?)
Parses a bool from this string, if it holds one.
- TryParseByte(string?)
Parses a byte from this string, if it holds one.
- TryParseByte(string?, NumberStyles, IFormatProvider)
Parses a byte from this string in the given style and culture, if it holds one.
- TryParseChar(string?)
Parses a char from this string, if it holds one character and no more.
- TryParseDateTime(string?)
Parses a DateTime from this string, if it holds one.
- TryParseDateTime(string?, IFormatProvider, DateTimeStyles)
Parses a DateTime from this string in the given culture and style, if it holds one.
- TryParseDateTimeExact(string?, string, IFormatProvider, DateTimeStyles)
Parses a DateTime from this string in the given format, if it holds one.
- TryParseDateTimeOffset(string?)
Parses a DateTimeOffset from this string, if it holds one.
- TryParseDateTimeOffset(string?, IFormatProvider, DateTimeStyles)
Parses a DateTimeOffset from this string in the given culture and style, if it holds one.
- TryParseDecimal(string?)
Parses a decimal from this string, if it holds one.
- TryParseDecimal(string?, NumberStyles, IFormatProvider)
Parses a decimal from this string in the given style and culture, if it holds one.
- TryParseDefinedEnum<TEnum>(string?)
Parses a declared member of the given enumeration type from this string, if it holds one.
- TryParseDefinedEnum<TEnum>(string?, bool)
Parses a declared member of the given enumeration type from this string, if it holds one, and the compare can be case-insensitive.
- TryParseDouble(string?)
Parses a double from this string, if it holds one.
- TryParseDouble(string?, NumberStyles, IFormatProvider)
Parses a double from this string in the given style and culture, if it holds one.
- TryParseEnum<TEnum>(string?)
Parses a value of the given enumeration type from this string, if it holds one.
- TryParseEnum<TEnum>(string?, bool)
Parses a value of the given enumeration type from this string, if it holds one, The compare can be case-insensitive.
- TryParseGuid(string?)
Parses a Guid from this string, if it holds one.
- TryParseGuidExact(string?, string)
Parses a Guid from this string in the given layout, if it holds one.
- TryParseInt16(string?)
Parses a short from this string, if it holds one.
- TryParseInt16(string?, NumberStyles, IFormatProvider)
Parses a short from this string in the given style and culture, if it holds one.
- TryParseInt32(string?)
Parses a int from this string, if it holds one.
- TryParseInt32(string?, NumberStyles, IFormatProvider)
Parses a int from this string in the given style and culture, if it holds one.
- TryParseInt64(string?)
Parses a long from this string, if it holds one.
- TryParseInt64(string?, NumberStyles, IFormatProvider)
Parses a long from this string in the given style and culture, if it holds one.
- TryParseSByte(string?)
Parses a sbyte from this string, if it holds one.
- TryParseSByte(string?, NumberStyles, IFormatProvider)
Parses a sbyte from this string in the given style and culture, if it holds one.
- TryParseSingle(string?)
Parses a float from this string, if it holds one.
- TryParseSingle(string?, NumberStyles, IFormatProvider)
Parses a float from this string in the given style and culture, if it holds one.
- TryParseTimeSpan(string?)
Parses a TimeSpan from this string, if it holds one.
- TryParseTimeSpan(string?, IFormatProvider)
Parses a TimeSpan from this string in the given culture, if it holds one.
- TryParseUInt16(string?)
Parses a ushort from this string, if it holds one.
- TryParseUInt16(string?, NumberStyles, IFormatProvider)
Parses a ushort from this string in the given style and culture, if it holds one.
- TryParseUInt32(string?)
Parses a uint from this string, if it holds one.
- TryParseUInt32(string?, NumberStyles, IFormatProvider)
Parses a uint from this string in the given style and culture, if it holds one.
- TryParseUInt64(string?)
Parses a ulong from this string, if it holds one.
- TryParseUInt64(string?, NumberStyles, IFormatProvider)
Parses a ulong from this string in the given style and culture, if it holds one.
- TryParseUri(string?)
Parses an absolute Uri from this string, if it holds one.
- TryParseUri(string?, UriKind)
Parses a Uri of the given type from this string, if it holds one.