• 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 AddPrefix

AddPrefix(String, String)

If value does NOT start with prefix then returns a new string with the prefix, otherwise returns value.

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

The value to add the prefix to.

System.String prefix

The prefix to be added.

Returns
Type Description
System.String

Either a new string without the specified prefix, or else the original string.

Remarks

This overload is case sensitive. For a case insensitive version use AddPrefix(String, String, Boolean) with ignoreCase set to true.

Exceptions
Type Condition
System.ArgumentNullException

Throw if either value or prefix is null.

AddPrefix(String, String, Boolean)

If value ends with prefix then returns a new string without the prefix, otherwise returns value.

Declaration
public static string AddPrefix(this string value, string prefix, bool ignoreCase)
Parameters
Type Name Description
System.String value

The value to add the prefix to.

System.String prefix

The prefix to be added.

System.Boolean ignoreCase

A boolean indicating whether or not to match the prefix in a case sensitive (true) or insensitive (false) manner.

Returns
Type Description
System.String

Either a new string without the specified prefix, or else the original string.

Remarks

This overload is case sensitive. For a case insensitive version use AddPrefix(String, String, Boolean) with ignoreCase set to true.

Exceptions
Type Condition
System.ArgumentNullException

Throw if either value or prefix is null.

Back to top Copyright (c) 2017 Troy Willmot