docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class StringExtensions

    Extension methods for System.String.

    Inheritance
    object
    StringExtensions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.Tutorials.Core.Editor
    Assembly: Unity.Tutorials.Core.Editor.dll
    Syntax
    public static class StringExtensions

    Methods

    AsEmptyIfNull(string)

    Returns an empty string ("") if this string is null.

    Declaration
    public static string AsEmptyIfNull(this string self)
    Parameters
    Type Name Description
    string self

    The string this function acts on

    Returns
    Type Description
    string

    An empty string if the string is null

    AsNullIfEmpty(string)

    Returns null if this string is null or an empty string ("").

    Declaration
    public static string AsNullIfEmpty(this string self)
    Parameters
    Type Name Description
    string self

    The string this function acts on

    Returns
    Type Description
    string

    null if the string is empty, the unmodified string otherwise

    AsNullIfWhiteSpace(string)

    Returns null if this string is not null, empty, or consists only of white-space characters.

    Declaration
    public static string AsNullIfWhiteSpace(this string self)
    Parameters
    Type Name Description
    string self

    The string this function acts on

    Returns
    Type Description
    string

    null if the string is only whitespace, the unmodified string otherwise

    IsNotNullOrEmpty(string)

    Indicates whether this string is not null or an empty string ("").

    Declaration
    public static bool IsNotNullOrEmpty(this string self)
    Parameters
    Type Name Description
    string self

    The string this function acts on

    Returns
    Type Description
    bool

    True if not null or empty

    IsNotNullOrWhiteSpace(string)

    Indicates whether this string is not null, empty, or consists only of white-space characters.

    Declaration
    public static bool IsNotNullOrWhiteSpace(this string self)
    Parameters
    Type Name Description
    string self

    The string this function acts on

    Returns
    Type Description
    bool

    True if not empty or only whitespace

    IsNullOrEmpty(string)

    Indicates whether this string is null or an empty string ("").

    Declaration
    public static bool IsNullOrEmpty(this string self)
    Parameters
    Type Name Description
    string self

    The string this function acts on

    Returns
    Type Description
    bool

    True if null or empty

    IsNullOrWhiteSpace(string)

    Indicates whether this string is null, empty, or consists only of white-space characters.

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

    The string this function acts on

    Returns
    Type Description
    bool

    True if null or whitespace only

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)