CultureInfo.GetFormat(Type) CultureInfo.GetFormat(Type) CultureInfo.GetFormat(Type) CultureInfo.GetFormat(Type) Method

定义

获取一个定义如何格式化指定类型的对象。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 Type Type Type

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

返回

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.

适用于

另请参阅