Class StringExtensions
- Namespace
- RisingV.Shared.Extensions
- Assembly
- RisingV.Shared.dll
Provides extension methods for string manipulation.
public static class StringExtensions
- Inheritance
-
StringExtensions
- Inherited Members
Methods
FloatHash(string)
Generates a float hash from a string.
public static float FloatHash(this string str)
Parameters
str
stringThe string to hash.
Returns
- float
A float hash value derived from the string.
FormatWith(string, params object[])
Like string.Format, but lets you write "{}" instead of "{0}", "{1}", ...
public static string FormatWith(this string format, params object[] args)
Parameters
Returns
IsNullOrEmpty(string?)
Checks if a string is null or empty.
public static bool IsNullOrEmpty(this string? str)
Parameters
str
stringThe string to check.
Returns
- bool
True if the string is null or empty; otherwise, false.
IsNullOrWhiteSpace(string?)
Checks if a string is null or whitespace.
public static bool IsNullOrWhiteSpace(this string? value)
Parameters
value
stringThe string to check.
Returns
- bool
True if the string is null or consists only of whitespace characters; otherwise, false.
MaybeAddSpace(string?)
Adds a space to the end of the string if it is not null or empty, ensuring that the string ends with a space.
public static string MaybeAddSpace(this string? str)
Parameters
str
stringThe string to process.
Returns
- string
A new string with a space added at the end if it was not null or empty, otherwise an empty string.
Repeat(string, uint)
Repeats a string a specified number of times.
public static string Repeat(this string str, uint count)
Parameters
Returns
- string
A new string that consists of the original string repeated the specified number of times.
ToBool(string)
Converts a string to a boolean.
public static bool ToBool(this string str)
Parameters
str
stringThe string to convert.
Returns
- bool
The boolean value represented by the string.
ToFloat(string)
Converts a string to a float.
public static float ToFloat(this string str)
Parameters
str
stringThe string to convert.
Returns
- float
The float value represented by the string.
ToInt(string)
Converts a string to an integer.
public static int ToInt(this string str)
Parameters
str
stringThe string to convert.
Returns
- int
The integer value represented by the string.
UnityColorTag(string, string)
Wraps text in a color tag with the specified hex color code.
public static string UnityColorTag(this string text, string hex)
Parameters
Returns
- string
Text wrapped in a Unity rich text color tag