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