logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class StringUtils

    Utility class for common string operations and formatting

    Inheritance
    object
    StringUtils
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Shared.Utils
    Assembly: Serenity.Shared.dll
    Syntax
    public static class StringUtils

    Methods

    Coalesce(params string[])

    Returns the first non-null/non-empty string from the provided options

    Declaration
    public static string Coalesce(params string[] options)
    Parameters
    Type Name Description
    string[] options

    String options to choose from

    Returns
    Type Description
    string

    First valid string, or empty string if all are null/empty

    FormatLogMessage(string, string)

    Creates a debug log message with a standardized prefix

    Declaration
    public static string FormatLogMessage(string prefix, string message)
    Parameters
    Type Name Description
    string prefix

    Log prefix (e.g., "[UI]", "[AssetPrefetcher]")

    string message

    Main log message

    Returns
    Type Description
    string

    Formatted log message with prefix

    FormatLogMessage(string, string, params object[])

    Creates a debug log message with prefix and formatted arguments

    Declaration
    public static string FormatLogMessage(string prefix, string template, params object[] args)
    Parameters
    Type Name Description
    string prefix

    Log prefix (e.g., "[UI]", "[AssetPrefetcher]")

    string template

    Message template with format placeholders

    object[] args

    Arguments to format into the template

    Returns
    Type Description
    string

    Formatted log message with prefix

    IsNullOrWhiteSpace(string)

    Checks if a string is null or whitespace

    Declaration
    public static bool IsNullOrWhiteSpace(string value)
    Parameters
    Type Name Description
    string value

    String to check

    Returns
    Type Description
    bool

    True if string is null, empty, or whitespace only

    SafeFormat(string, params object[])

    Safely formats a string with arguments, handling null and invalid format strings

    Declaration
    public static string SafeFormat(string template, params object[] args)
    Parameters
    Type Name Description
    string template

    Format template string

    object[] args

    Arguments to format into the template

    Returns
    Type Description
    string

    Formatted string, or error message if formatting fails

    In this article
    © 2026 Serenity. All Rights Reserved