DelimitedString Class
Definition
Provides a set of static methods to convert a sequence into a delimited string and break a delimited string into substrings.
public static class DelimitedString
- Inheritance
-
DelimitedString
Examples
The following example shows how to create a delimited string from an array of integers and split it back into parts using DelimitedString. The delimiter and string converter are configured through setup options.
using System;
using System.Globalization;
using Cuemon;
namespace MyApp.Delimited;
public class DelimitedStringExample
{
public void Demonstrate()
{
var numbers = new[] { 1, 2, 3, 4, 5 };
string csv = DelimitedString.Create(numbers, o =>
{
o.Delimiter = ",";
o.StringConverter = value => value.ToString();
});
Console.WriteLine(csv); // "1,2,3,4,5"
string[] parts = DelimitedString.Split(csv, o =>
{
o.Delimiter = ",";
});
Console.WriteLine(string.Join(" | ", parts)); // "1 | 2 | 3 | 4 | 5"
}
}
Methods
| Name | Description |
|---|---|
| Create<T>(IEnumerable<T>, Action<DelimitedStringOptions<T>>) | Creates a delimited string representation from the specified |
| Split(string, Action<DelimitedStringOptions>) | Splits the specified |