public void StringReadonlySpanTest() { ReadOnlySpan <string> sample = ExpectedString.Split(' '); var actual = PreInputted.ToStringBuilder(); sample.AppendToStringBuilder(actual, CharSeparator); actual.Is(PreInputted, ExpectedString, " ", CharSeparator); actual = PreInputted.ToStringBuilder(); sample.AppendToStringBuilder(actual, StringSeparator); actual.Is(PreInputted, ExpectedString, " ", StringSeparator); }
/// <summary> /// Concatenates the string of the provided ReadonlySpan, /// using the specified separator between each string. /// Then create the StringBuilder from it. /// </summary> /// <param name="source">An ReadonlyMemory that contains the string.</param> /// <param name="separator">Specify the separator.</param> /// <returns>A StringBuilder that contain the concatenated the specified strings with specified separator.</returns> public static StringBuilder ToStringBuilder(this ReadOnlySpan <string> source, string separator) => source.AppendToStringBuilder(new StringBuilder(), separator);
/// <summary> /// Concatenates the string of the provided string ReadOnlySpan, /// using the specified separator between each string. /// Then appends the result and finally default line terminator to the designated StringBuilder. /// </summary> /// <param name="source">A string ReadOnlySpan for concatenates.</param> /// <param name="stringBuilder">A StringBuilder to be appended.</param> /// <param name="separator">Specify the separator.</param> /// <returns>A reference to the designated instance after the append operation has completed.</returns> public static StringBuilder AppendToStringBuilderAsLine(this ReadOnlySpan <string> source, StringBuilder stringBuilder, string separator) => source.AppendToStringBuilder(stringBuilder, separator).AppendLine();