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
argTThe parameter (参数).
Returns
- string
A string that represents the current object (表示当前对象的字符串).
Type Parameters
TType 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
formatin which any format items are replaced by the string representation ofarg0.
Exceptions
- ArgumentNullException
formatis null.- FormatException
The format item in
formatis 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
formatstringA composite format string.
arg0objectThe first object to format.
arg1objectThe second object to format.
Returns
- string
A copy of
formatin which format items are replaced by the string representations ofarg0andarg1.
Exceptions
- ArgumentNullException
formatis null.- FormatException
formatis 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
formatstringA composite format string.
arg0objectThe first object to format.
arg1objectThe second object to format.
arg2objectThe third object to format.
Returns
- string
A copy of
formatin which the format items have been replaced by the string representations ofarg0,arg1, andarg2.
Exceptions
- ArgumentNullException
formatis null.- FormatException
formatis 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
formatstringA composite format string.
argsobject[]An object array that contains zero or more objects to format.
Returns
- string
A copy of
formatin which the format items have been replaced by the string representation of the corresponding objects inargs.
Exceptions
- ArgumentNullException
formatorargsis null.- FormatException
formatis invalid.-or-
The index of a format item is less than zero, or greater than or equal to the length of the
argsarray.
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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatstringA composite format string.
arg0objectThe object to format.
Returns
- string
A copy of
formatin which the format item or items have been replaced by the string representation ofarg0.
Exceptions
- ArgumentNullException
formatis null.- FormatException
formatis 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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatstringA composite format string.
arg0objectThe first object to format.
arg1objectThe second object to format.
Returns
- string
A copy of
formatin which format items are replaced by the string representations ofarg0andarg1.
Exceptions
- ArgumentNullException
formatis null.- FormatException
formatis 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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatstringA composite format string.
arg0objectThe first object to format.
arg1objectThe second object to format.
arg2objectThe third object to format.
Returns
- string
A copy of
formatin which the format items have been replaced by the string representations ofarg0,arg1, andarg2.
Exceptions
- ArgumentNullException
formatis null.- FormatException
formatis 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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatstringA composite format string.
argsobject[]An object array that contains zero or more objects to format.
Returns
- string
A copy of
formatin which the format items have been replaced by the string representation of the corresponding objects inargs.
Exceptions
- ArgumentNullException
formatorargsis null.- FormatException
formatis invalid.-or-
The index of a format item is less than zero, or greater than or equal to the length of the
argsarray.
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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatCompositeFormatarg0TArg0The first object to format.
Returns
- string
The formatted string.
Type Parameters
TArg0The type of the first object to format.
Exceptions
- ArgumentNullException
formatis 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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatCompositeFormatarg0TArg0The first object to format.
arg1TArg1The second object to format.
Returns
- string
The formatted string.
Type Parameters
TArg0The type of the first object to format.
TArg1The type of the second object to format.
Exceptions
- ArgumentNullException
formatis 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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatCompositeFormatarg0TArg0The first object to format.
arg1TArg1The second object to format.
arg2TArg2The third object to format.
Returns
- string
The formatted string.
Type Parameters
TArg0The type of the first object to format.
TArg1The type of the second object to format.
TArg2The type of the third object to format.
Exceptions
- ArgumentNullException
formatis 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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatCompositeFormatargsobject[]An array of objects to format.
Returns
- string
The formatted string.
Exceptions
- ArgumentNullException
formatorargsis 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
providerIFormatProviderAn object that supplies culture-specific formatting information.
formatCompositeFormatargsReadOnlySpan<object>A span of objects to format.
Returns
- string
The formatted string.
Exceptions
- ArgumentNullException
formatis null.- FormatException
The index of a format item is greater than or equal to the number of supplied arguments.