Method Format
- Namespace
- Zyl.VectorTraits
- Assembly
- VectorTraits.dll
Format<T>(T)
Returns a string that represents the current object. It is used to replace the ToString method for vector types and no longer throws exceptions (返回表示当前对象的字符串. 用于替代向量类型的 ToString 方法. 它用于替换向量类型的 ToString 方法,不再抛出异常).
public static string Format<T>(T arg)
Parameters
arg
TThe parameter (参数).
Returns
- string
A string that represents the current object (表示当前对象的字符串).
Type Parameters
T
Type of parameter (参数的类型).
Format(string, object?)
Replaces one or more format items in a string with the string representation of a specified object.
public static string Format(string format, object? arg0)
Parameters
Returns
- string
A copy of
format
in which any format items are replaced by the string representation ofarg0
.
Exceptions
- ArgumentNullException
format
is null.- FormatException
The format item in
format
is invalid.-or-
The index of a format item is not zero.
Format(string, object?, object?)
Replaces the format items in a string with the string representation of two specified objects.
public static string Format(string format, object? arg0, object? arg1)
Parameters
format
stringA composite format string.
arg0
objectThe first object to format.
arg1
objectThe second object to format.
Returns
- string
A copy of
format
in which format items are replaced by the string representations ofarg0
andarg1
.
Exceptions
- ArgumentNullException
format
is null.- FormatException
format
is invalid.-or-
The index of a format item is not zero or one.
Format(string, object?, object?, object?)
Replaces the format items in a string with the string representation of three specified objects.
public static string Format(string format, object? arg0, object? arg1, object? arg2)
Parameters
format
stringA composite format string.
arg0
objectThe first object to format.
arg1
objectThe second object to format.
arg2
objectThe third object to format.
Returns
- string
A copy of
format
in which the format items have been replaced by the string representations ofarg0
,arg1
, andarg2
.
Exceptions
- ArgumentNullException
format
is null.- FormatException
format
is invalid.-or-
The index of a format item is less than zero, or greater than two.
Format(string, params object?[])
Replaces the format item in a specified string with the string representation of a corresponding object in a specified array.
public static string Format(string format, params object?[] args)
Parameters
format
stringA composite format string.
args
object[]An object array that contains zero or more objects to format.
Returns
- string
A copy of
format
in which the format items have been replaced by the string representation of the corresponding objects inargs
.
Exceptions
- ArgumentNullException
format
orargs
is null.- FormatException
format
is invalid.-or-
The index of a format item is less than zero, or greater than or equal to the length of the
args
array.
Format(IFormatProvider?, string, object?)
Replaces the format item or items in a specified string with the string representation of the corresponding object. A parameter supplies culture-specific formatting information.
public static string Format(IFormatProvider? provider, string format, object? arg0)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
stringA composite format string.
arg0
objectThe object to format.
Returns
- string
A copy of
format
in which the format item or items have been replaced by the string representation ofarg0
.
Exceptions
- ArgumentNullException
format
is null.- FormatException
format
is invalid.-or-
The index of a format item is not zero.
Format(IFormatProvider?, string, object?, object?)
Replaces the format items in a string with the string representation of two specified objects. A parameter supplies culture-specific formatting information.
public static string Format(IFormatProvider? provider, string format, object? arg0, object? arg1)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
stringA composite format string.
arg0
objectThe first object to format.
arg1
objectThe second object to format.
Returns
- string
A copy of
format
in which format items are replaced by the string representations ofarg0
andarg1
.
Exceptions
- ArgumentNullException
format
is null.- FormatException
format
is invalid.-or-
The index of a format item is not zero or one.
Format(IFormatProvider?, string, object?, object?, object?)
Replaces the format items in a string with the string representation of three specified objects. An parameter supplies culture-specific formatting information.
public static string Format(IFormatProvider? provider, string format, object? arg0, object? arg1, object? arg2)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
stringA composite format string.
arg0
objectThe first object to format.
arg1
objectThe second object to format.
arg2
objectThe third object to format.
Returns
- string
A copy of
format
in which the format items have been replaced by the string representations ofarg0
,arg1
, andarg2
.
Exceptions
- ArgumentNullException
format
is null.- FormatException
format
is invalid.-or-
The index of a format item is less than zero, or greater than two.
Format(IFormatProvider?, string, params object?[])
Replaces the format items in a string with the string representations of corresponding objects in a specified array. A parameter supplies culture-specific formatting information.
public static string Format(IFormatProvider? provider, string format, params object?[] args)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
stringA composite format string.
args
object[]An object array that contains zero or more objects to format.
Returns
- string
A copy of
format
in which the format items have been replaced by the string representation of the corresponding objects inargs
.
Exceptions
- ArgumentNullException
format
orargs
is null.- FormatException
format
is invalid.-or-
The index of a format item is less than zero, or greater than or equal to the length of the
args
array.
Format<TArg0>(IFormatProvider?, CompositeFormat, TArg0)
Replaces the format item or items in a CompositeFormat with the string representation of the corresponding objects in the specified format.
public static string Format<TArg0>(IFormatProvider? provider, CompositeFormat format, TArg0 arg0)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
CompositeFormatarg0
TArg0The first object to format.
Returns
- string
The formatted string.
Type Parameters
TArg0
The type of the first object to format.
Exceptions
- ArgumentNullException
format
is null.- FormatException
The index of a format item is greater than or equal to the number of supplied arguments.
Format<TArg0, TArg1>(IFormatProvider?, CompositeFormat, TArg0, TArg1)
Replaces the format item or items in a CompositeFormat with the string representation of the corresponding objects in the specified format.
public static string Format<TArg0, TArg1>(IFormatProvider? provider, CompositeFormat format, TArg0 arg0, TArg1 arg1)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
CompositeFormatarg0
TArg0The first object to format.
arg1
TArg1The second object to format.
Returns
- string
The formatted string.
Type Parameters
TArg0
The type of the first object to format.
TArg1
The type of the second object to format.
Exceptions
- ArgumentNullException
format
is null.- FormatException
The index of a format item is greater than or equal to the number of supplied arguments.
Format<TArg0, TArg1, TArg2>(IFormatProvider?, CompositeFormat, TArg0, TArg1, TArg2)
Replaces the format item or items in a CompositeFormat with the string representation of the corresponding objects in the specified format.
public static string Format<TArg0, TArg1, TArg2>(IFormatProvider? provider, CompositeFormat format, TArg0 arg0, TArg1 arg1, TArg2 arg2)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
CompositeFormatarg0
TArg0The first object to format.
arg1
TArg1The second object to format.
arg2
TArg2The third object to format.
Returns
- string
The formatted string.
Type Parameters
TArg0
The type of the first object to format.
TArg1
The type of the second object to format.
TArg2
The type of the third object to format.
Exceptions
- ArgumentNullException
format
is null.- FormatException
The index of a format item is greater than or equal to the number of supplied arguments.
Format(IFormatProvider?, CompositeFormat, params object?[])
Replaces the format item or items in a CompositeFormat with the string representation of the corresponding objects in the specified format.
public static string Format(IFormatProvider? provider, CompositeFormat format, params object?[] args)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
CompositeFormatargs
object[]An array of objects to format.
Returns
- string
The formatted string.
Exceptions
- ArgumentNullException
format
orargs
is null.- FormatException
The index of a format item is greater than or equal to the number of supplied arguments.
Format(IFormatProvider?, CompositeFormat, ReadOnlySpan<object?>)
Replaces the format item or items in a CompositeFormat with the string representation of the corresponding objects in the specified format.
public static string Format(IFormatProvider? provider, CompositeFormat format, ReadOnlySpan<object?> args)
Parameters
provider
IFormatProviderAn object that supplies culture-specific formatting information.
format
CompositeFormatargs
ReadOnlySpan<object>A span of objects to format.
Returns
- string
The formatted string.
Exceptions
- ArgumentNullException
format
is null.- FormatException
The index of a format item is greater than or equal to the number of supplied arguments.