RandomNumberGenerator.GetHexString 方法

定义

重载

GetHexString(Int32, Boolean)

创建一个用加密随机十六进制字符填充的字符串。

GetHexString(Span<Char>, Boolean)

使用加密随机十六进制字符填充缓冲区。

GetHexString(Int32, Boolean)

Source:
RandomNumberGenerator.cs
Source:
RandomNumberGenerator.cs

创建一个用加密随机十六进制字符填充的字符串。

C#
public static string GetHexString(int stringLength, bool lowercase = false);

参数

stringLength
Int32

要创建的字符串的长度。

lowercase
Boolean

true 如果十六进制字符应为小写; false 如果它们应为大写,则为 。 默认为 false

返回

用随机十六进制字符填充的字符串。

注解

此行为的行为与使用 GetString(ReadOnlySpan<Char>, Int32) 和指定十六进制字符作为选项相同。 此实现专门针对十六进制字符进行优化。

适用于

.NET 10 和其他版本
产品 版本
.NET 8, 9, 10

GetHexString(Span<Char>, Boolean)

Source:
RandomNumberGenerator.cs
Source:
RandomNumberGenerator.cs

使用加密随机十六进制字符填充缓冲区。

C#
public static void GetHexString(Span<char> destination, bool lowercase = false);

参数

destination
Span<Char>

要接收字符的缓冲区。

lowercase
Boolean

true 如果十六进制字符应为小写; false 如果它们应为大写,则为 。 默认为 false

注解

此行为的行为与使用 GetItems<T>(ReadOnlySpan<T>, Span<T>) 和指定十六进制字符作为选项相同。 此实现专门针对十六进制字符进行优化。

适用于

.NET 10 和其他版本
产品 版本
.NET 8, 9, 10