Table of Contents

Stem Class

Definition

Namespace
Cuemon.Text
Assemblies
Cuemon.Core.dll
Source
src/Cuemon.Core/Text/Stem.cs

Provides a way to support assigning a stem to a value.

public sealed class Stem
Inheritance
Stem

Examples

The following example demonstrates how to use Stem to build a URL path by attaching prefixes and suffixes without duplication.

using Cuemon.Text;

namespace MyApp.Examples;

public class StemExample
{
    public void Demonstrate()
    {
        var path = new Stem("api")
            .AttachPrefix("/")
            .AttachSuffix("/")
            .AttachSuffix("v1")
            .AttachSuffix("/")
            .AttachSuffix("users");

        var result = path.ToString();
        // result == "/api/v1/users"

}
}

Constructors

Name Description
Stem(string)

Initializes a new instance of the Stem class.

Properties

Name Description
Value

Gets the value of this instance.

Methods

Name Description
AttachPrefix(string)

Attaches the specified prefix to the stem of this instance.

AttachPrefix(string, Func<string, bool>)

Attaches the specified prefix to the stem of this instance.

AttachSuffix(string)

Attaches the specified suffix to the stem of this instance.

AttachSuffix(string, Func<string, bool>)

Attaches the specified suffix to the stem of this instance.

ToString()

Returns a string that represents the current object.

Operators

Name Description
implicit operator string(Stem)

Performs an implicit conversion from Stem to string.

implicit operator Stem(string)

Performs an implicit conversion from string to Stem.