• 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 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 value.

System.String value

The value to append.

Returns
Type Description
System.Text.StringBuilder

A reference to builder.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if builder is null.

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 valueFactory.

System.Func<System.String> valueFactory

The value to append.

Returns
Type Description
System.Text.StringBuilder

A reference to builder.

Exceptions
Type Condition
System.ArgumentNullException

Thrown if builder or valueFactory are null.

Back to top Copyright (c) 2017 Troy Willmot