Struct StringView
Represents a view of a string which is represented in memory like an std::basic_string_view from the C++
standard library.
public readonly struct StringView : ISpanFormattable, IFormattable
- Implements
- Inherited Members
Constructors
StringView(byte*, Size)
Initializes a new instance of the StringView struct.
public StringView(byte* data, Size size)
Parameters
Methods
AsSpan()
Converts this view to a read-only span of bytes.
public ReadOnlySpan<byte> AsSpan()
Returns
- ReadOnlySpan<byte>
The readonly span of bytes.
ToString()
public override string? ToString()
Returns
- string
The converted string.
ToString(string?, IFormatProvider?)
Converts this view to a string using UTF-8 encoding.
public string ToString(string? format, IFormatProvider? formatProvider)
Parameters
formatstringThe format to use.
formatProviderIFormatProviderThe provider to use to format the value.
Returns
TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)
Tries to format the value of this string view into the provided span of characters. The string view is converted using UTF-8 encoding.
public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider)
Parameters
destinationSpan<char>The span in which to write this instance's value formatted as a span of characters.
charsWrittenintWhen this method returns, contains the number of characters that were written in
destination.formatReadOnlySpan<char>A span containing the characters that represent a standard or custom format string that defines the acceptable format for
destination.providerIFormatProviderAn optional object that supplies culture-specific formatting information for
destination.
Returns
Operators
implicit operator string?(StringView)
Converts a StringView to a string using UTF-8 encoding.
public static implicit operator string?(StringView view)
Parameters
viewStringView