Show / Hide Table of Contents
  • MaybeSharp
    • Maybe<T>
      • As
      • Bind
      • Cast
      • CompareTo
      • Equality
      • Equals
      • Explicit
      • GetHashCode
      • GreaterThan
      • GreaterThanOrEqual
      • HasValue
      • Implicit
      • Inequality
      • IsEmpty
      • LessThan
      • LessThanOrEqual
      • Maybe
      • Nothing
      • ToString
      • Value
  • MaybeSharp.Extensions
    • MaybeDictionaryExtensions
      • TryGetValue
    • MaybeExtensions
      • Coalesce
      • Or
      • Select
      • SelectMany
      • SelectNonempty
      • ToNullable
      • ValueOr
      • ValueOrException
      • WhenNothing
      • WhenSomething
      • Where
    • MaybeStringExtensions
      • TryParseBoolean
      • TryParseByte
      • TryParseChar
      • TryParseDateTime
      • TryParseDateTimeOffset
      • TryParseDecimal
      • TryParseDouble
      • TryParseInt
      • TryParseInt16
      • TryParseInt64
      • TryParseSingle
    • NullableExtensions
      • ToMaybe

Struct Maybe<T>

Represents a value that might be 'empty' or a valid value.

Implements
IEquatable<Maybe<T>>
IEquatable<T>
IFormattable
IComparable
IComparable<Maybe<T>>
IComparable<T>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Namespace: MaybeSharp
Assembly: cs.temp.dll.dll
Syntax
public struct Maybe<T> : IEquatable<Maybe<T>>, IEquatable<T>, IFormattable, IComparable, IComparable<Maybe<T>>, IComparable<T>
Type Parameters
Name Description
T

Constructors

Name Description
Maybe(T)

Creates an instance that represents the specified value.

Fields

Name Description
Nothing

Represents an empty version of this maybe.

Properties

Name Description
HasValue

Returns true if this instance contains a valid, non-empty value.

IsEmpty

Returns true if this instance is empty.

Value

If HasValue is true, returns the value contained by this instance, otherwise throws a .

Methods

Name Description
As<TResult>()

If this maybe is empty, returns an empty Maybe{TResult}. If this maybe is not empty, use the as keyword to convert it's value to TResult and returns a new maybe containing the result.

Bind(Func<T, Maybe<T>>)

If this maybe is not empty, calls the specified function providing the value of this maybe and returns the result. If this maybe is nothing, returns an empty maybe.

Bind<TResult>(Func<T, Maybe<TResult>>)

If this maybe is not empty, calls the specified function providing the value of this maybe and returns the result. If this maybe is nothing, returns an empty maybe.

Cast<TResult>()

If this maybe is empty, returns an empty Maybe{TResult}. If this maybe is not empty, casts it's value to TResult and returns a new maybe containing the result. If the cast fails, an empty Maybe{TResult} is returned.

CompareTo(T)

Compares this instance to a value of {T}.

CompareTo(Maybe<T>)

Compares this instance to another instance of Maybe{T}.

CompareTo(Object)

Compares this instance to the value specified.

Equals(T)

Performs an equality check.

Equals(Maybe<T>)

Performs an equality check.

Equals(Object)

Performs an equality check.

GetHashCode()

Returns the hashcode for this instance.

ToString()

Returns the string <nothing> if IsEmpty is true, otherwise returns the result of the ToString method of the inner Value.

ToString(String, IFormatProvider)

Formats the value of the current instance using the specified format.

Operators

Name Description
Equality(Maybe<T>, Maybe<T>)

Performs equality checking on Maybe{T} instances.

Explicit(Maybe<T> to T)

Explicitly converts a Maybe{T} to it's {T} value if it is non-empty, otherwise throws an .

GreaterThan(Maybe<T>, T)

Returns true if m1 is greater than m2.

GreaterThan(Maybe<T>, Maybe<T>)

Returns true if m1 is greater than m2.

GreaterThanOrEqual(Maybe<T>, T)

Returns true if m1 is greater than m2.

GreaterThanOrEqual(Maybe<T>, Maybe<T>)

Returns true if m1 is greater than m2.

Implicit(T to Maybe<T>)

Allows implicit conversion from {T} to a Maybe{T} instance.

Inequality(Maybe<T>, Maybe<T>)

Performs inequality checking on Maybe{T} instances.

LessThan(Maybe<T>, T)

Returns true if m1 is less than m2.

LessThan(Maybe<T>, Maybe<T>)

Returns true if m1 is less than m2.

LessThanOrEqual(Maybe<T>, T)

Returns true if m1 is less than m2.

LessThanOrEqual(Maybe<T>, Maybe<T>)

Returns true if m1 is less than m2.

Back to top Copyright (c) 2017 Troy Willmot