Class StringExtensions
Inheritance
Namespace: TetraCreations.Core
Assembly: cs.temp.dll.dll
Syntax
public static class StringExtensions
Methods
Concat(string, string, string)
Concatenates three string
Declaration
public static string Concat(this string str0, string str1, string str2)
Parameters
Type | Name | Description |
---|---|---|
string | str0 | The first string to concatenate. |
string | str1 | The second string to concatenate. |
string | str2 | The third string to concatenate. |
Returns
Type | Description |
---|---|
string |
Concat(string, string)
Concatenates two string
Declaration
public static string Concat(this string str0, string str1)
Parameters
Type | Name | Description |
---|---|---|
string | str0 | The first string to concatenate. |
string | str1 | The second string to concatenate. |
Returns
Type | Description |
---|---|
string |
Extract(string, Func<char, bool>)
Extract the portion of the string which match the predicate
Declaration
public static string Extract(this string source, Func<char, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
string | source | The string to act on. |
Func<, ><char, bool> | predicate |
Returns
Type | Description |
---|---|
string | A string. |
ExtractInt32(string)
Extracts the integer from the string.
Declaration
public static int ExtractInt32(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source | The string to act on. |
Returns
Type | Description |
---|---|
int |
Format(string, params object[])
Allow to use string.Format directly from the string like "Hello {0}".Format("World"), output => Hello World
Declaration
public static string Format(this string format, params object[] args)
Parameters
Type | Name | Description |
---|---|---|
string | format | |
object[] | args |
Returns
Type | Description |
---|---|
string |
GetAfter(string, string)
Get the string after the specified string.
Declaration
public static string GetAfter(this string source, string value)
Parameters
Type | Name | Description |
---|---|---|
string | source | The string to act on. |
string | value | The value to search. |
Returns
Type | Description |
---|---|
string | The string after the specified value. |
GetBefore(string, string)
Get the string before the specified string.
Declaration
public static string GetBefore(this string source, string value)
Parameters
Type | Name | Description |
---|---|---|
string | source | The string to act on. |
string | value | The value to search. |
Returns
Type | Description |
---|---|
string | The string before the specified value. |
GetBetween(string, string, string)
Get the string between the two specified string.
Declaration
public static string GetBetween(this string source, string before, string after)
Parameters
Type | Name | Description |
---|---|---|
string | source | The string to act on. |
string | before | The string before to search. |
string | after | The string after to search. |
Returns
Type | Description |
---|---|
string | The string between the two specified string. |
GetInvalidFilenameCharacters(string)
Return an IEnumerable of char which are invalid for a file name.
Declaration
public static IEnumerable<char> GetInvalidFilenameCharacters(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
IEnumerable<><char> |
GetInvalidPathCharacters(string)
Return an IEnumerable of char which are invalid for a file name.
Declaration
public static IEnumerable<char> GetInvalidPathCharacters(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
IEnumerable<><char> |
HasAnyInvalidChars(string)
Determine if a string has any invalid character as a file name.
Declaration
public static bool HasAnyInvalidChars(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
bool |
IsNnotNullOrEmpty(string)
Returns true if the string is Not null or empty
Declaration
public static bool IsNnotNullOrEmpty(this string value)
Parameters
Type | Name | Description |
---|---|---|
string | value |
Returns
Type | Description |
---|---|
bool |
IsNullOrEmpty(string)
Allow to use string.IsNullOrEmpty directly from the string
Declaration
public static bool IsNullOrEmpty(this string value)
Parameters
Type | Name | Description |
---|---|---|
string | value |
Returns
Type | Description |
---|---|
bool |
Log(string, DebugLevel, bool)
Log the string in the console.
Declaration
public static void Log(this string source, DebugLevel debugLevel = DebugLevel.None, bool debug = true)
Parameters
Type | Name | Description |
---|---|---|
string | source | The string to Log. |
DebugLevel | debugLevel | Choose which Debug.Log method to call (Normal, Warning, Error) |
bool | debug | Set to false to prevent log |
ParsePercentageToFloat(string)
Converts the string formated as a percentage to float value, for example '10.2%'.ParsePercentageString() returns 10.2f
Declaration
public static float ParsePercentageToFloat(this string value)
Parameters
Type | Name | Description |
---|---|---|
string | value |
Returns
Type | Description |
---|---|
float |
RemoveInvalidChars(string)
Return a string without any invalid character as a file name.
Declaration
public static string RemoveInvalidChars(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
string |
RemoveSpaces(string)
Return the string without any spaces.
Declaration
public static string RemoveSpaces(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
string |
ToIntOrNull(string)
Try to parse the string to an int
Declaration
public static int? ToIntOrNull(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
int? |
ToSentenceCase(string)
Convert a pascal case string to a sentence.
Declaration
public static string ToSentenceCase(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
string |
UppercaseFirst(string)
Set the first character to upper case.
Declaration
public static string UppercaseFirst(this string source)
Parameters
Type | Name | Description |
---|---|---|
string | source |
Returns
Type | Description |
---|---|
string |