SystemStringExtensions

Namespace: System · class

Methods

CreateInvariant

static string CreateInvariant(ref InvariantInterpolatedStringHandler handler)

Creates a new string by using the InvariantCulture to control the formatting of the specified interpolated string.

  • handler — The interpolated string.

Returns: The string that results for formatting the interpolated string using the invariant format provider.

This is a shortcut to string.Create(CultureInfo.InvariantCulture, $"...");

TryCopyTo

static bool TryCopyTo(string source, Span<char> destination, out int written)

Calls TryCopyTo and, if successful, sets the number of copied items in written

  • destination — The span to copy items into
  • written — Number of characters copied, or 0 if destination is too small

Returns: If the destination span is shorter than the source span, this method return false and no data is written to the destination.

This helper method is very useful when implementing ISpanFormattable.