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