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);
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 類別的 Type 物件,則這會是包含目前 CultureInfo 之預設數值格式資訊的 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 類別的 Type 物件,則這會是包含目前 CultureInfo 之預設日期及時間格式資訊的 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- Null,如果 formatType 是任何其他物件。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.

適用於

另請參閱