Skip to content

String Extensions

JasperFx.Core provides several extension methods for common string operations.

Usage

csharp
using JasperFx.Core;

Examples

cs
public void StringHelpers()
{
    // Convert to camel case
    var camel = "SomePropertyName".ToCamelCase();
    // => "somePropertyName"

    // Check if a string is empty or whitespace
    var isEmpty = "".IsEmpty();
    var isNotEmpty = "hello".IsNotEmpty();

    // Joining strings
    var joined = new[] { "one", "two", "three" }.Join(", ");
}

snippet source | anchor

Available Methods

MethodDescription
ToCamelCase()Converts PascalCase to camelCase
IsEmpty()Returns true if the string is null, empty, or whitespace
IsNotEmpty()Inverse of IsEmpty()
Join(separator)Joins an enumerable of strings with a separator
ToDelimitedString(delimiter)Converts a collection to a delimited string
EqualsIgnoreCase(other)Case-insensitive string comparison
Matches(pattern)Regex match helper
SplitOnNewLine()Splits on \n and \r\n
ToFullPath()Resolves a relative path to a full filesystem path

Null Safety

Most string extensions handle null input gracefully:

csharp
string? value = null;
value.IsEmpty();    // true
value.IsNotEmpty(); // false

Next Steps

Released under the MIT License.