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 |
See Also
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 |
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 |
Remarks
If otherValues
is null, then value
is returned.
See Also
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 |
Remarks
If otherValues
is null, then value
is returned.