NamespaceSystemLibrary.Common.Framework.Extensions SystemLibrary.Common.Framework.Net.dll
Extension methods for ReadOnlySpan
ReadOnlySpanExtensions
public static class ReadOnlySpanExtensions
Inheritance
object
ReadOnlySpanExtensions
Examples
Arguments
X
Methods
Converts the ReadOnlySpan of Char to a byte array
public static byte[] GetBytes(this ReadOnlySpan<char> span, Encoding encoding = null)
X
var textSpan = "Hello World".AsSpan();
var bytes = textSpan.GetBytes();
X
Type | Description |
---|---|
byte[] | Byte array or null if input was so |
Checks if span is null or length is 0
public static bool IsNot<T>(this ReadOnlySpan<T> span)
X
var textSpan = "Hello World".AsSpan();
var isSpan = textSpan.IsNot(); // False, as span is not null, and has text length > 0
X
Type | Description |
---|---|
bool | True or false |
Checks if span is not null and length is larger than 0
public static bool Is<T>(this ReadOnlySpan<T> span)
X
var textSpan = "Hello World".AsSpan();
var isSpan = textSpan.Is(); // True, span is not null
X
Type | Description |
---|---|
bool | True or false |
Convert a ReadOnlySpan of char to Base64
public static string ToBase64(this ReadOnlySpan<char> span, Encoding encoding = null)
X
var textSpan = "Hello World".AsSpan();
var base64 = textSpan.ToBase64();
X
Type | Description |
---|---|
string | Base64 string or null if input was so |
}