Edit

Share via


RandomNumberGenerator.GetString(ReadOnlySpan<Char>, Int32) Method

Definition

Creates a string populated with characters chosen at random from choices.

public static string GetString(ReadOnlySpan<char> choices, int length);

Parameters

choices
ReadOnlySpan<Char>

The characters to use to populate the string.

length
Int32

The length of string to return.

Returns

A string populated with random choices.

Exceptions

choices is empty.

length is not zero or a positive number.

Applies to

Product Versions
.NET 8, 9, 10