PutridParrot.Options/OptionalExtensions.cs
/// <summary>
/// SafeCast is the same as a standard cast but no exception occurs, instead
/// a Optional.None would be returned for a cast failure.
/// </summary>
/// <typeparam name="TFrom"></typeparam>
/// <typeparam name="TTo"></typeparam>
/// <param name="optional"></param>
/// <returns></returns>
SafeCast is the same as a standard cast but no exception occurs, instead
a Optional.None would be returned for a cast failure.
SafeCast is the same as a standard cast but no exception occurs instead a Optional . None would be returned for a cast failure .
public static Optional<TTo> SafeCast<TFrom, TTo>(this Optional<TFrom> optional)
            where TTo : class
        {
            var cast = optional.Value as TTo;
            return cast.ToOptional();
        }
public static Optional < TTo > SafeCast < TFrom , TTo > ( this Optional < TFrom > optional ) where TTo : class { var cast = optional . Value as TTo ; return cast . ToOptional ( ) ; }
SafeCast is the same as a standard cast but no exception occurs, instead
a Optional.None would be returned for a cast failure.
SafeCast is the same as a standard cast but no exception occurs instead a Optional . None would be returned for a cast failure .
None
Optional<TFrom>
this
optional
None
typeparam
None
typeparam
None