Class ParseResult<T>
The result of a parse operation.
Since 1.0.x
Availability net45, netstandard1.3
Inheritance
Object
ParseResult<T>
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: NodaTime.Text
Assembly: NodaTime.dll
Syntax
public sealed class ParseResult<T>
Type Parameters
Name | Description |
---|---|
T | The type which was parsed, such as a LocalDateTime. |
Properties
Exception
Gets an exception indicating the cause of the parse failure.
Since 1.2.x
Availability net45, netstandard1.3
Declaration
public Exception Exception { get; }
Property Value
Type | Description |
---|---|
Exception | The exception indicating the cause of the parse failure. |
Remarks
This property is typically used to wrap parse failures in higher level exceptions.
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The parse operation succeeded. |
Success
Indicates whether the parse operation was successful.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public bool Success { get; }
Property Value
Type | Description |
---|---|
Boolean | true if the parse operation was successful; otherwise false. |
Remarks
This returns True if and only if fetching the value with the Value property will return with no exception.
Value
Gets the value from the parse operation if it was successful, or throws an exception indicating the parse failure
otherwise.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public T Value { get; }
Property Value
Type | Description |
---|---|
T | The result of the parsing operation if it was successful. |
Remarks
This method is exactly equivalent to calling the GetValueOrThrow() method, but is terser if the code is
already clear that it will throw if the parse failed.
Methods
GetValueOrThrow()
Gets the value from the parse operation if it was successful, or throws an exception indicating the parse failure
otherwise.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public T GetValueOrThrow()
Returns
Type | Description |
---|---|
T | The result of the parsing operation if it was successful. |
Remarks
This method is exactly equivalent to fetching the Value property, but more explicit in terms of throwing
an exception on failure.
TryGetValue(T, out T)
Returns the success value, and sets the out parameter to either
the specified failure value of T or the successful parse result value.
Since 1.0.x
Availability net45, netstandard1.3
Declaration
public bool TryGetValue(T failureValue, out T result)
Parameters
Type | Name | Description |
---|---|---|
T | failureValue | The "default" value to set in result if parsing failed. |
T | result | The parameter to store the parsed value in on success. |
Returns
Type | Description |
---|---|
Boolean | True if this parse result was successful, or false otherwise. |