Method Coalesce
Coalesce(String[])
Returns the first non-null, non-empty and non-whitespace string from those provided. If there is no non-null, non-empty string containing at least one non-whitespace character in values
then null is returned.
Declaration
public static string Coalesce(this string[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | A set of strings to coalesce. |
Returns
Type | Description |
---|---|
System.String | Returns a System.String if a non blank value is found, otherwise returns null. |
Remarks
This overload treats strings containing only whitespace characters as being empty.
Coalesce(String[], CoalesceOptions)
Returns the first non-null, non-empty string from those provided. If there is no non-null, non-empty string in values
then null is returned.
Declaration
public static string Coalesce(this string[] values, CoalesceOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | A set of strings to coalesce. |
CoalesceOptions | options | A value from the CoalesceOptions enum specifying options for deciding when to coalesce a value. |
Returns
Type | Description |
---|---|
System.String | Returns a System.String if a non blank value is found, otherwise returns null. |
Coalesce(IEnumerable<String>)
Returns the first non-null, non-empty string from those provided. If there is no non-null, non-empty string containing at least one non-whitespace character in values
then null is returned.
Declaration
public static string Coalesce(this IEnumerable<string> values)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | values | A set of strings to coalesce. |
Returns
Type | Description |
---|---|
System.String | Returns a System.String if a non blank value is found, otherwise returns null. |
Remarks
This overload treats strings containing only whitespace characters as being empty.
Coalesce(IEnumerable<String>, CoalesceOptions)
Returns the first non-null, non-empty string from those provided. If there is no non-null, non-empty string in values
then null is returned.
Declaration
public static string Coalesce(this IEnumerable<string> values, CoalesceOptions options)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | values | A set of strings to coalesce. |
CoalesceOptions | options | A value from the CoalesceOptions enum specifying options for deciding when to coalesce a value. |
Returns
Type | Description |
---|---|
System.String | Returns a System.String if a non blank value is found, otherwise returns null. |