CultureInfo.GetFormat(Type) 方法

定义

获取一个定义如何格式化指定类型的对象。Gets an object that defines how to format the specified type.

public:
 virtual System::Object ^ GetFormat(Type ^ formatType);
public virtual object GetFormat (Type formatType);
abstract member GetFormat : Type -> obj
override this.GetFormat : Type -> obj
Public Overridable Function GetFormat (formatType As Type) As Object

参数

formatType
Type

要为其获取格式化对象的 TypeThe Type for which to get a formatting object. 此方法仅支持 NumberFormatInfoDateTimeFormatInfo 两种类型。This method only supports the NumberFormatInfo and DateTimeFormatInfo types.

返回

Object

NumberFormat 属性的值,如果 formatTypeNumberFormatInfo 类的 CultureInfo 对象,则该属性为包含当前 Type 的默认数字格式信息的 NumberFormatInfoThe value of the NumberFormat property, which is a NumberFormatInfo containing the default number format information for the current CultureInfo, if formatType is the Type object for the NumberFormatInfo class.

- 或 --or- DateTimeFormat 属性的值,如果 formatTypeDateTimeFormatInfo 类的 CultureInfo 对象,则该属性为包含当前 Type 的默认日期和时间格式信息的 DateTimeFormatInfoThe value of the DateTimeFormat property, which is a DateTimeFormatInfo containing the default date and time format information for the current CultureInfo, if formatType is the Type object for the DateTimeFormatInfo class.

- 或 --or- 如果 formatType 为任何其他对象,则为 null。null, if formatType is any other object.

实现

注解

GetFormat 可实现 IFormatProvider.GetFormatGetFormat implements IFormatProvider.GetFormat.

NumberFormatInfo 提供与基本数据类型中的格式方法结合使用的区域性特定的数字格式。NumberFormatInfo provides the culture-specific numeric format used in conjunction with the Format methods in the base data types. DateTimeFormatInfo 控制如何针对特定区域性设置日期和时间值的格式。DateTimeFormatInfo controls how the date and time values are formatted for a specific culture.

适用于

另请参阅