Struct StringValue
Represents an option/monad item that wraps an string value and allows conversion to most common types.
public readonly struct StringValue : ICloneable, IEquatable<StringValue>, IComparable<StringValue>
- Implements
- Inherited Members
Constructors
- StringValue(string)
Creates an new empty value of the StringValue with no predefined value.
- StringValue(string, string?)
Creates an new value of the StringValue.
Properties
- IsNull
Gets an boolean indicating if this object value is null.
- IsNullOrEmpty
Gets an boolean indicating if this object value is null or an empty string.
- Name
Gets the name of the property that hosts this StringValue.
- Value
Gets the value of the current StringValue string if it has been assigned a valid underlying value.
Methods
- CompareTo(StringValue, in StringComparison)
Compares the current object with another object of the same type, using the specified string comparison.
- Create(string?)
Creates an new StringValue from the specified string.
- GetBoolean()
Parses the value contained in this StringValue as a bool. Throws an exception if the value couldn't be parsed to the target type.
- GetByte(IFormatProvider?)
Parses the value contained in this StringValue as a byte. Throws an exception if the value couldn't be parsed to the target type.
- GetChar()
Parses the value contained in this StringValue as a char. Throws an exception if the value couldn't be parsed to the target type.
- GetDateTime(IFormatProvider?)
Parses the value contained in this StringValue as a DateTime. Throws an exception if the value couldn't be parsed to the target type.
- GetDecimal(IFormatProvider?)
Parses the value contained in this StringValue as a decimal. Throws an exception if the value couldn't be parsed to the target type.
- GetDouble(IFormatProvider?)
Parses the value contained in this StringValue as a double. Throws an exception if the value couldn't be parsed to the target type.
- GetEnum<TEnum>()
Gets an Enum object representation from this StringValue, parsing the current string expression into an value of
TEnum
. This method will throw an NullReferenceException if the value stored in this instance is null.
- GetGuid(IFormatProvider?)
Parses the value contained in this StringValue as a Guid. Throws an exception if the value couldn't be parsed to the target type.
- GetInteger(IFormatProvider?)
Parses the value contained in this StringValue as an int. Throws an exception if the value couldn't be parsed to the target type.
- GetLong(IFormatProvider?)
Parses the value contained in this StringValue as a long. Throws an exception if the value couldn't be parsed to the target type.
- GetShort(IFormatProvider?)
Parses the value contained in this StringValue as a short. Throws an exception if the value couldn't be parsed to the target type.
- GetSingle(IFormatProvider?)
Parses the value contained in this StringValue as a float. Throws an exception if the value couldn't be parsed to the target type.
- GetString()
Gets a non-null string from this StringValue. This method will throw an NullReferenceException if the value stored in this instance is null.
- Get<T>(IFormatProvider?)
Parses the value contained in this StringValue as a type
T
that implements IParsable<TSelf>. Throws an exception if the value couldn't be parsed to the target type.
- MaybeNull()
Returns a self-reference to this object when it's value is not null.
- MaybeNullOrEmpty()
Returns a self-reference to this object when it's value is not null or an empty string.