C# Class mstum.utils.Extensions.StringExtensions

Mostrar archivo Open project: mstum/mstum.utils

Public Methods

Method Description
IfEmpty ( this input, string otherString ) : string

If input is null or empty, return otherString

http://www.stum.de/2010/01/16/extension-method-return-another-string-if-string-is-null-or-empty/

ReplaceAll ( this input, string>.IDictionary replacements ) : string

Replace all occurences of a certain char with a string

http://www.stum.de/2010/02/16/an-extension-method-to-replace-multiple-chars-in-a-string/

SafeSubstring ( this input, int startIndex, int length, string suffix = "" ) : string

A safe Substring method that does not throw an exception if startIndex or length is out of bounds of the string

http://www.stum.de/2009/02/27/a-safe-stringsubstring-extension-method/

Use ( this input ) : string

A shortcut for string.Format

http://www.stum.de/2009/08/20/turning-string-format-into-an-extension-method/

Method Details

IfEmpty() public static method

If input is null or empty, return otherString
http://www.stum.de/2010/01/16/extension-method-return-another-string-if-string-is-null-or-empty/
public static IfEmpty ( this input, string otherString ) : string
input this
otherString string
return string

ReplaceAll() public static method

Replace all occurences of a certain char with a string
http://www.stum.de/2010/02/16/an-extension-method-to-replace-multiple-chars-in-a-string/
public static ReplaceAll ( this input, string>.IDictionary replacements ) : string
input this
replacements string>.IDictionary A dictionary where the key is a char to replace and the value is the string to replace it with. Value can be null.
return string

SafeSubstring() public static method

A safe Substring method that does not throw an exception if startIndex or length is out of bounds of the string
http://www.stum.de/2009/02/27/a-safe-stringsubstring-extension-method/
public static SafeSubstring ( this input, int startIndex, int length, string suffix = "" ) : string
input this
startIndex int
length int
suffix string An optional suffix to append if the string is truncated
return string

Use() public static method

A shortcut for string.Format
http://www.stum.de/2009/08/20/turning-string-format-into-an-extension-method/
public static Use ( this input ) : string
input this
return string