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

定義

使用指定的回呼,建立具有特定長度的新字串,並在建立後予以初始化。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

類型參數

TState

要傳遞至的元素類型 actionThe type of the element to pass to action.

參數

length
Int32

要建立的字串長度。The length of the string to create.

state
TState

要傳遞至 action 的元素。The element to pass to action.

action
SpanAction<Char,TState>

初始化字串的回呼。A callback to initialize the string.

傳回

String

已建立的字串。The created string.

備註

傳遞至之目的範圍的初始內容 action 未定義。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.

適用於