Class StringExtensions
Class StringExtensions.
Inheritance
Namespace: ISynergy.Framework.Core.Extensions
Assembly: ISynergy.Framework.Core.dll
Syntax
public static class StringExtensions : object
Methods
View SourceBreakLine(String, Int32, Int32)
Locates position to break the given line so as to avoid breaking words.
Declaration
public static int BreakLine(this string text, int pos, int max)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | String that contains line of text |
System.Int32 | pos | Index where line of text starts |
System.Int32 | max | Maximum line length |
Returns
Type | Description |
---|---|
System.Int32 | The modified line length |
Chop(String)
Chops the specified self.
Declaration
public static string Chop(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.String | System.String. |
CountLines(String)
Counts the lines.
Declaration
public static int CountLines(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.Int32 | System.Int32. |
CovertString2Numeric(String)
Coverts the string2 numeric.
Declaration
public static int CovertString2Numeric(this string _self)
Parameters
Type | Name | Description |
---|---|---|
System.String | _self | The self. |
Returns
Type | Description |
---|---|
System.Int32 | System.Int32. |
ExtractHexDigits(String)
Extract only the hex digits from a string.
Declaration
public static string ExtractHexDigits(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.String | System.String. |
FirstLine(String)
Firsts the line.
Declaration
public static string FirstLine(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.String | System.String. |
Format(String, Object[])
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
Declaration
public static string Format(this string str, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | A composite format string. |
System.Object[] | args | An object array that contains zero or more objects to format. |
Returns
Type | Description |
---|---|
System.String | A copy of str in which the format items have been replaced by the string representation of the corresponding objects in args. |
GetBytes(String, Int32, Int32)
Gets the bytes.
Declaration
public static byte[] GetBytes(this string value, int start, int NumBytes)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value. |
System.Int32 | start | The start. |
System.Int32 | NumBytes | The number bytes. |
Returns
Type | Description |
---|---|
System.Byte[] | System.Byte[]. |
HasMethod<T>(String)
Checks whether a type implements a method with the given name.
Declaration
public static bool HasMethod<T>(string methodName)
Parameters
Type | Name | Description |
---|---|---|
System.String | methodName | Name of the method. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Type Parameters
Name | Description |
---|---|
T |
HexStringToColor(String)
Convert a hex string to a .NET Color object.
Declaration
public static Color HexStringToColor(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | a hex string: "FFFFFF", "#000000" |
Returns
Type | Description |
---|---|
Color | Color. |
IncreaseString2Long(String, Int64)
Increases the string2 long.
Declaration
public static string IncreaseString2Long(this string self, long summand)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
System.Int64 | summand | The summand. |
Returns
Type | Description |
---|---|
System.String | System.String. |
IsAlphaNumeric(String)
Determines whether [is alpha numeric] [the specified s].
Declaration
public static bool IsAlphaNumeric(this string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The s. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsDecimal(String)
Determines whether the specified self is decimal.
Declaration
public static bool IsDecimal(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsFloat(String)
Determines whether the specified self is float.
Declaration
public static bool IsFloat(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsInteger(String)
Determines whether the specified self is integer.
Declaration
public static bool IsInteger(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsNullOrEmptyOrEquals(String, String, StringComparison)
Determine if specified strings are null or empty or the strings are equal.
Declaration
public static bool IsNullOrEmptyOrEquals(this string a, string b, StringComparison comparisonType)
Parameters
Type | Name | Description |
---|---|---|
System.String | a | String to compare |
System.String | b | String to compare |
StringComparison | comparisonType | StringComparison |
Returns
Type | Description |
---|---|
System.Boolean | True if the strings are null or empty or the strings are equal |
LastCharAt(String, Int32)
Lasts the character at.
Declaration
public static char LastCharAt(this string self, int pos)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
System.Int32 | pos | The position. |
Returns
Type | Description |
---|---|
System.Char | System.Char. |
MakeProper(String)
Makes the proper.
Declaration
public static string MakeProper(this string s)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The s. |
Returns
Type | Description |
---|---|
System.String | System.String. |
Remove(String, IEnumerable<Char>)
Removes the specified chars.
Declaration
public static string Remove(this string s, IEnumerable<char> chars)
Parameters
Type | Name | Description |
---|---|---|
System.String | s | The s. |
IEnumerable<System.Char> | chars | The chars. |
Returns
Type | Description |
---|---|
System.String | System.String. |
RemoveLastChar(String)
Removes the last character.
Declaration
public static string RemoveLastChar(this string self)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
Returns
Type | Description |
---|---|
System.String | System.String. |
ReplaceLastOf(String, String, String)
Replaces the last of.
Declaration
public static string ReplaceLastOf(this string str, string fromStr, string toStr)
Parameters
Type | Name | Description |
---|---|---|
System.String | str | The string. |
System.String | fromStr | From string. |
System.String | toStr | To string. |
Returns
Type | Description |
---|---|
System.String | System.String. |
SplitAndKeep(String, Char[])
Splits the string by delimiter, but keeps the delimiter.
Declaration
public static IList<string> SplitAndKeep(this string _self, params char[] delimiters)
Parameters
Type | Name | Description |
---|---|---|
System.String | _self | The self. |
System.Char[] | delimiters | The delimiters. |
Returns
Type | Description |
---|---|
IList<System.String> | IList<System.String>. |
SplitAt(String, Int32[])
Splits at.
Declaration
public static IEnumerable<string> SplitAt(this string self, params int[] positions)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
System.Int32[] | positions | The positions. |
Returns
Type | Description |
---|---|
IEnumerable<System.String> | IEnumerable<System.String>. |
ToCamelWithSeparator(String, Char)
Converts to camelwithseparator.
Declaration
public static string ToCamelWithSeparator(this string source, char separator)
Parameters
Type | Name | Description |
---|---|---|
System.String | source | The source. |
System.Char | separator | The separator. |
Returns
Type | Description |
---|---|
System.String | System.String. |
ToCapitalized(String, Char)
Converts string to a capitalized one where delimiter starts an new capitalization. Default delimiter is a dot.
Declaration
public static string ToCapitalized(this string _self, char delimiter = '.')
Parameters
Type | Name | Description |
---|---|---|
System.String | _self | The self. |
System.Char | delimiter | The delimiter. |
Returns
Type | Description |
---|---|
System.String | System.String. |
ToCapitalizedFirstLetter(String)
Converts string to a capitalized one where delimiter starts an new capitalization. Default delimiter is a space.
Declaration
public static string ToCapitalizedFirstLetter(this string _self)
Parameters
Type | Name | Description |
---|---|---|
System.String | _self | The self. |
Returns
Type | Description |
---|---|
System.String | System.String. |
ToEndingWithDirectorySeparator(String)
Declaration
public static string ToEndingWithDirectorySeparator(this string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path |
Returns
Type | Description |
---|---|
System.String |
ToEnum<T>(String, T)
Converts to enum.
Declaration
public static T ToEnum<T>(this string _self, T defaultValue)
where T : struct
Parameters
Type | Name | Description |
---|---|---|
System.String | _self | The value. |
T | defaultValue | The default value. |
Returns
Type | Description |
---|---|
T | T. |
Type Parameters
Name | Description |
---|---|
T |
ToSnakeCase(String)
Convert string to snake casing.
Declaration
public static string ToSnakeCase(this string input)
Parameters
Type | Name | Description |
---|---|---|
System.String | input | The input. |
Returns
Type | Description |
---|---|
System.String | System.String. |
TrimEnd(String, Int32)
Trims the end.
Declaration
public static string TrimEnd(this string self, int len)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
System.Int32 | len | The length. |
Returns
Type | Description |
---|---|
System.String | System.String. |
WordWrap(String, Int32)
Words the wrap.
Declaration
public static string WordWrap(this string self, int width)
Parameters
Type | Name | Description |
---|---|---|
System.String | self | The self. |
System.Int32 | width | The width. |
Returns
Type | Description |
---|---|
System.String | System.String. |
Wrap(String, Int32)
Wraps the specified width.
Declaration
public static string Wrap(this string a, int width)
Parameters
Type | Name | Description |
---|---|---|
System.String | a | a. |
System.Int32 | width | The width. |
Returns
Type | Description |
---|---|
System.String | System.String. |