Method AppendIf
AppendIf(StringBuilder, Boolean, String)
Appends value
only if condition
is true, otherwise does nothing.
Declaration
public static StringBuilder AppendIf(this StringBuilder builder, bool condition, string value)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | builder | The System.Text.StringBuilder to append to. |
System.Boolean | condition | A boolean indicating whether or not to actually append |
System.String | value | The value to append. |
Returns
Type | Description |
---|---|
System.Text.StringBuilder | A reference to |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |
AppendIf(StringBuilder, Boolean, Func<String>)
Appends the result of valueFactory
only if condition
is true, otherwise does nothing.
Declaration
public static StringBuilder AppendIf(this StringBuilder builder, bool condition, Func<string> valueFactory)
Parameters
Type | Name | Description |
---|---|---|
System.Text.StringBuilder | builder | The System.Text.StringBuilder to append to. |
System.Boolean | condition | A boolean indicating whether or not to actually append the value of |
System.Func<System.String> | valueFactory | The value to append. |
Returns
Type | Description |
---|---|
System.Text.StringBuilder | A reference to |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if |