Table of Contents

Method ToString

Namespace
Zyl.VectorTraits
Assembly
VectorTraits.dll

ToString(FormattableString)

Safely convert interpolated string to string. Based on FormattableString (安全地将内插字符串转为 string. 基于 FormattableString).

public static string ToString(FormattableString message)

Parameters

message FormattableString

The format (格式).

Returns

string

Formatted string (格式化之后的字符串).

Remarks

When a vector type contains an ExType, an exception occurs if the vector type is directly interpolated. With this method, the format can be done safely (当向量类型里含有 ExType 时, 若直接使用内插字符串, 会有异常. 而使用本办法后, 能安全地进行格式化).

var temp = Vectors<int>.Serial.ExAsExInt128();
// Bug! - Console.Out.WriteLine($"InterpolatedString:\t{temp}."); // System.NotSupportedException: Specified type is not supported
Console.Out.WriteLine(ExVectorUtil.ToString($"InterpolatedString:\t{temp}.")); // Successes.

ToString(IFormatProvider?, FormattableString)

Safely convert interpolated string to string, with provider parameter. Based on FormattableString (安全地将内插字符串转为 string, 带有 provider 参数. 基于 FormattableString).

public static string ToString(IFormatProvider? provider, FormattableString message)

Parameters

provider IFormatProvider

An object that provides culture-specific formatting information (一个提供区域性特定的格式设置信息的对象).

message FormattableString

The format (格式).

Returns

string

Formatted string (格式化之后的字符串).