public static string Create( string?format, IFormatProvider?formatProvider, Span <char> initialBuffer, [InterpolatedStringHandlerArgument("format", "formatProvider", "initialBuffer")] ref FormatInterpolatedStringHandler handler) { return(handler.ToStringAndClear()); }
/// <summary> /// Creates a handler used to write an interpolated string into a <see cref="Span{Char}"/>. /// </summary> /// <param name="literalLength">The number of constant characters outside of interpolation expressions in the interpolated string.</param> /// <param name="formattedCount">The number of interpolation expressions in the interpolated string.</param> /// <param name="destination">The destination buffer.</param> /// <param name="format">The format to use, if available.</param> /// <param name="formatProvider">An object that supplies culture-specific formatting information.</param> /// <param name="shouldAppend">Upon return, true if the destination may be long enough to support the formatting, or false if it won't be.</param> /// <remarks>This is intended to be called only by compiler-generated code. Arguments are not validated as they'd otherwise be for members intended to be used directly.</remarks> public TryWriteFormatInterpolatedStringHandler(int literalLength, int formattedCount, Span <char> destination, ReadOnlySpan <char> format, IFormatProvider?formatProvider, out bool shouldAppend) { this.destination = destination; this.format = format; this.formatAsString = null; this.formatProvider = formatProvider; position = 0; success = shouldAppend = destination.Length >= literalLength; hasCustomFormatter = formatProvider is not null && FormatInterpolatedStringHandler.HasCustomFormatter(formatProvider); }