• Home
  • API Documentation
Show / Hide Table of Contents
  • Mozzarella
    • ByteArrayExtensions
      • AsString
      • ToHexString
    • CoalesceOptions
      • None
      • WhiteSpaceAsEmpty
    • EnumerableOfStringExtensions
      • Coalesce
    • ErasableString
      • Clear
      • Dispose
      • ErasableString
      • IsCleared
      • IsDisposed
      • Value
    • StringBuilderExtensions
      • Append
      • AppendIf
      • AppendJoin
      • Contains
      • IndexOf
      • LastIndexOf
      • ToLower
      • ToUpper
      • Trim
      • TrimEnd
      • TrimStart
    • StringExtensions
      • AddPrefix
      • AddSuffix
      • AfterFirst
      • AfterLast
      • BeforeFirst
      • BeforeLast
      • CICompare
      • CIContains
      • CIEquals
      • CIReplace
      • Coalesce
      • Contains
      • ContainsOnly
      • IndexOfFirstDifference
      • IsAllDigits
      • IsAlphanumeric
      • IsNullOrEmpty
      • IsNullOrWhiteSpace
      • IsOnlyAlphas
      • IsOnlyDigits
      • LevenshteinDistanceTo
      • Like
      • NullIfEmpty
      • OCICompare
      • OCIContains
      • OCIEquals
      • OCIReplace
      • OEquals
      • PascalCaseToWords
      • RemoveAllExcept
      • RemoveAllWhiteSpace
      • RemoveNonAlphanumerics
      • RemoveNonAlphas
      • Replace
      • StripNonDigits
      • StripPrefix
      • StripSuffix
      • Truncate
  • Mozzarella.Tests
    • RemoveNonAlphanumerics
      • RemoveNonAlphanumerics_DoesNotRemoveNumerics
      • RemoveNonAlphanumerics_RemovesNonAlphanumerics
      • RemoveNonAlphanumerics_ReturnsEmptyForEmpty
      • RemoveNonAlphanumerics_ReturnsNullForNull
      • RemoveNonAlphanumerics_ReturnsOriginalStringWhenNoCharactersRemoved
    • RemoveNonAlphas
      • RemoveNonAlphas_RemovesNonNumericNonAlphas
      • RemoveNonAlphas_RemovesNumerics
      • RemoveNonAlphas_ReturnsEmptyForEmpty
      • RemoveNonAlphas_ReturnsNullForNull
      • RemoveNonAlphas_ReturnsOriginalStringWhenNoCharactersRemoved

Method Coalesce

Coalesce(String, String)

Returns otherValue if value is null, empty or contains only whitespace characters, otherwise returns value.

Declaration
public static string Coalesce(this string value, string otherValue)
Parameters
Type Name Description
System.String value

The first value to return if it is not considered empty.

System.String otherValue

The second value to return if the first is considered empty.

Returns
Type Description
System.String

Either value or otherValue depending on which is empty.

See Also
Coalesce(String, CoalesceOptions, String)
Coalesce(String, String[])

Coalesce(String, CoalesceOptions, String)

Returns otherValue if value is considered empty, otherwise returns value.

Declaration
public static string Coalesce(this string value, CoalesceOptions options, string otherValue)
Parameters
Type Name Description
System.String value

The first value to return if it is not considered empty.

CoalesceOptions options

A set of flags from the CoalesceOptions controlling how the method behaves.

System.String otherValue

The second value to return if the first is considered empty.

Returns
Type Description
System.String

Either value or otherValue depending on which is empty.

Remarks

Whether or not a value is considered empty can be controlled (partially) via the options argument.

Coalesce(String, String[])

Returns value if it is not empty, otherwise returns the first non-empty, non-null, non-whitespace string from otherValues.

Declaration
public static string Coalesce(this string value, params string[] otherValues)
Parameters
Type Name Description
System.String value

The first value to return if it is not considered empty.

System.String[] otherValues

An array of values, in preferred order, the first non-empty, non-null, non-whitespace value to be returned.

Returns
Type Description
System.String

Either value or the first non-empty/null/whitespace value from otherValues.

Remarks

If otherValues is null, then value is returned.

See Also
Coalesce(String, CoalesceOptions, String[])
Coalesce(String, CoalesceOptions, String)

Coalesce(String, CoalesceOptions, String[])

Returns value if it is not empty, otherwise returns the first non-empty, non-null, non-whitespace string from otherValues.

Declaration
public static string Coalesce(this string value, CoalesceOptions options, params string[] otherValues)
Parameters
Type Name Description
System.String value

The first value to return if it is not considered empty.

CoalesceOptions options

A set of flags from the CoalesceOptions controlling how the method behaves.

System.String[] otherValues

An array of values, in preferred order, the first non-empty, non-null, non-whitespace value to be returned.

Returns
Type Description
System.String

Either value or the first non-empty/null/whitespace value from otherValues.

Remarks

If otherValues is null, then value is returned.

See Also
Coalesce(String, CoalesceOptions, String)
Coalesce(String, String[])
Back to top Copyright (c) 2017 Troy Willmot