Table of Contents

Class DelimitedStringOptions<T>

Namespace
Cuemon
Assembly
Cuemon.Core.dll

Configuration options for DelimitedString.

public class DelimitedStringOptions<T> : IParameterObject

Type Parameters

T

The type of the object to convert.

Inheritance
DelimitedStringOptions<T>
Implements

Examples

The following example demonstrates how to use to configure the conversion of a sequence of objects into a delimited string.

using System;
using System.Globalization;
using Cuemon;

namespace Contoso.Telemetry;

public sealed class DelimitedStringOptionsOfTExample
{
    public static void Run()
    {
        var options = new DelimitedStringOptions<int>
        {
            Delimiter = " | ",
            StringConverter = number => number.ToString("X2", CultureInfo.InvariantCulture)
        };

        int[] numbers = { 1, 2, 3, 4 };
        string hex = DelimitedString.Create(numbers, setup =>
        {
            setup.Delimiter = options.Delimiter;
            setup.StringConverter = options.StringConverter;
        });

        Console.WriteLine(hex);
    }
}

Constructors

DelimitedStringOptions()

Initializes a new instance of the DelimitedStringOptions<T> class.

public DelimitedStringOptions()

Remarks

The following table shows the initial property values for an instance of DelimitedStringOptions<T>.

PropertyInitial Value
Delimiter,
StringConvertero => o.ToString()

Properties

Delimiter

Gets or sets the delimiter specification.

public string Delimiter { get; set; }

Property Value

string

The delimiter specification.

Exceptions

ArgumentNullException

value cannot be null.

ArgumentException

value cannot be empty.

StringConverter

Gets or sets the function delegate that converts T to a string representation.

public Func<T, string> StringConverter { get; set; }

Property Value

Func<T, string>

The function delegate that converts T to a string representation.

Exceptions

ArgumentNullException

value cannot be null.