String.Create<TState>(Int32, TState, SpanAction<Char,TState>) Method

Definition

Creates a new string with a specific length and initializes it after creation by using the specified callback.

public:
generic <typename TState>
 static System::String ^ Create(int length, TState state, System::Buffers::SpanAction<char, TState> ^ action);
public static string Create<TState> (int length, TState state, System.Buffers.SpanAction<char,TState> action);
static member Create : int * 'State * System.Buffers.SpanAction<char, 'State> -> string
Public Shared Function Create(Of TState) (length As Integer, state As TState, action As SpanAction(Of Char, TState)) As String

Type Parameters

TState

The type of the element to pass to action.

Parameters

length
Int32

The length of the string to create.

state
TState

The element to pass to action.

action
SpanAction<Char,TState>

A callback to initialize the string.

Returns

String

The created string.

Remarks

The initial content of the destination span passed to action is undefined. Therefore, it is the delegate's responsibility to ensure that every element of the span is assigned. Otherwise, the resulting string could contain random characters.

Applies to