C# Class BudgetAnalyser.Engine.StringExtension

An extension class for string.
Afficher le fichier Open project: Benrnz/BudgetAnalyser

Méthodes publiques

Méthode Description
AnOrA ( this instance, bool properCase = false ) : string

Returns the appropriate 'An' or 'A' prefix for the given string. The given string is not included in the return text.

IsNothing ( this instance ) : bool

Returns true if the string is null, whitespace or empty. Equivelant to IsNullOrWhiteSpace

IsSomething ( this instance ) : bool

Returns true if the string is not null, not whitespace, and not empty. The direct opporsite of IsNothing

SplitLines ( this instance, int numberOfLines ) : string[]

An extension to the string.Split(char[]) method. This method splits at new line characters, trims off trailing whitespace, and returns the specified number of lines.

TrimEndSafely ( this instance ) : string

Trims the end of a string safely. If the string is null, null is returned.

Truncate ( this instance, int truncateToLength, bool useEllipses = false ) : string

Truncates the right of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.

TruncateLeft ( this instance, int truncateToLength, bool useEllipses = false ) : string

Truncates the left of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.

Method Details

AnOrA() public static méthode

Returns the appropriate 'An' or 'A' prefix for the given string. The given string is not included in the return text.
public static AnOrA ( this instance, bool properCase = false ) : string
instance this The string to determine the prefix for.
properCase bool A boolean to indicate if the prefix should be proper-cased or not.
Résultat string

IsNothing() public static méthode

Returns true if the string is null, whitespace or empty. Equivelant to IsNullOrWhiteSpace
public static IsNothing ( this instance ) : bool
instance this
Résultat bool

IsSomething() public static méthode

Returns true if the string is not null, not whitespace, and not empty. The direct opporsite of IsNothing
public static IsSomething ( this instance ) : bool
instance this
Résultat bool

SplitLines() public static méthode

An extension to the string.Split(char[]) method. This method splits at new line characters, trims off trailing whitespace, and returns the specified number of lines.
public static SplitLines ( this instance, int numberOfLines ) : string[]
instance this
numberOfLines int
Résultat string[]

TrimEndSafely() public static méthode

Trims the end of a string safely. If the string is null, null is returned.
public static TrimEndSafely ( this instance ) : string
instance this
Résultat string

Truncate() public static méthode

Truncates the right of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.
public static Truncate ( this instance, int truncateToLength, bool useEllipses = false ) : string
instance this
truncateToLength int
useEllipses bool
Résultat string

TruncateLeft() public static méthode

Truncates the left of a string to the specified length, but only if it exceeds that length. Optionally the returned string can include ellipses.
public static TruncateLeft ( this instance, int truncateToLength, bool useEllipses = false ) : string
instance this
truncateToLength int
useEllipses bool
Résultat string