forked from npgsql/npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringBuilderExtensions.cs
More file actions
34 lines (32 loc) · 1.05 KB
/
StringBuilderExtensions.cs
File metadata and controls
34 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#if NETSTANDARD2_0 || NET461
using System;
using System.Text;
namespace Npgsql.Util
{
/// <summary>
/// A set of extension methods to <see cref="StringBuilder"/> to allow runtime compatibility.
/// </summary>
static class StringBuilderExtensions
{
/// <summary>
/// Appends the provided <see cref="ReadOnlySpan{T}"/> to the <see cref="StringBuilder"/>.
/// </summary>
/// <param name="stringBuilder">The <see cref="StringBuilder"/> to append to.</param>
/// <param name="span">The <see cref="ReadOnlySpan{T}"/> to append.</param>
public static StringBuilder Append(this StringBuilder stringBuilder, ReadOnlySpan<char> span)
{
if (span.Length > 0)
{
unsafe
{
fixed (char* value = &span.GetPinnableReference())
{
return stringBuilder.Append(value, span.Length);
}
}
}
return stringBuilder;
}
}
}
#endif