C# Class Rolcore.StringExtensions

Extensions for String.
Datei anzeigen Open project: Rollins/Rolcore

Public Methods

Method Description
EnsureTrailing ( this s, char c ) : string

Checks that the string ends with the specified character. If it doesn't then the character is appended.

First ( this s, int numberOfCharacters ) : string

Returns the first part of a string, up to a specified number of characters.

FromBase64String ( this s ) : string

Converts the string from a Base64 encoded string to a "regular" string.

FromBase64UriSafeString ( this s ) : string

Converts the string from a Base64 encoded string to a "regular" string.

IsPalindrome ( this s ) : bool

Determines if the given string is a palindrome (can be read the same forwards and backwards).

Repeat ( this s, int numberOfTimes ) : string

Repeats a string some number of times.

Reverse ( this s ) : string

Reverses the given string.

ToBase64String ( this s ) : string

Converts the string to a Base64 encoded string.

ToBase64UriSafeString ( this s ) : string

Converts the string to a URI-safe Base64 encoded string. Read about URL and file safe base64 encoding at http://tools.ietf.org/html/rfc4648#page-7.

ToSHA1String ( this s ) : string

Computes a SHA-1 hash of the specified string.

ToUri ( this s, Uri baseUri = null ) : Uri

Converts the string to a Uri.

Method Details

EnsureTrailing() public static method

Checks that the string ends with the specified character. If it doesn't then the character is appended.
public static EnsureTrailing ( this s, char c ) : string
s this Specifies the string to check.
c char Specifies the character to check for.
return string

First() public static method

Returns the first part of a string, up to a specified number of characters.
public static First ( this s, int numberOfCharacters ) : string
s this The string from which to get the sub string.
numberOfCharacters int The number of characters to get from the string
return string

FromBase64String() public static method

Converts the string from a Base64 encoded string to a "regular" string.
public static FromBase64String ( this s ) : string
s this The string to decode.
return string

FromBase64UriSafeString() public static method

Converts the string from a Base64 encoded string to a "regular" string.
public static FromBase64UriSafeString ( this s ) : string
s this The string to decode.
return string

IsPalindrome() public static method

Determines if the given string is a palindrome (can be read the same forwards and backwards).
public static IsPalindrome ( this s ) : bool
s this Specifies the string to check.
return bool

Repeat() public static method

Repeats a string some number of times.
public static Repeat ( this s, int numberOfTimes ) : string
s this The string to be repeated.
numberOfTimes int The number of times to repeat the string. A value of zero /// returns an empty string, a value of one returns the original string, a value of two or /// more returns the string repeated that number of times.
return string

Reverse() public static method

Reverses the given string.
public static Reverse ( this s ) : string
s this Specfies the string to reverse.
return string

ToBase64String() public static method

Converts the string to a Base64 encoded string.
public static ToBase64String ( this s ) : string
s this The string to encode
return string

ToBase64UriSafeString() public static method

Converts the string to a URI-safe Base64 encoded string. Read about URL and file safe base64 encoding at http://tools.ietf.org/html/rfc4648#page-7.
public static ToBase64UriSafeString ( this s ) : string
s this The string to encode
return string

ToSHA1String() public static method

Computes a SHA-1 hash of the specified string.
public static ToSHA1String ( this s ) : string
s this The string to hash.
return string

ToUri() public static method

Converts the string to a Uri.
public static ToUri ( this s, Uri baseUri = null ) : Uri
s this Specifies the string to convert.
baseUri System.Uri Optionally specifies the base URI if the specified string is (or might be) relative.
return System.Uri