DateTimeFormatInfo.GetInstance(IFormatProvider) 方法

定義

傳回與指定 DateTimeFormatInfo 關聯的 IFormatProvider 物件。Returns the DateTimeFormatInfo object associated with the specified IFormatProvider.

public:
 static System::Globalization::DateTimeFormatInfo ^ GetInstance(IFormatProvider ^ provider);
public static System.Globalization.DateTimeFormatInfo GetInstance (IFormatProvider provider);
static member GetInstance : IFormatProvider -> System.Globalization.DateTimeFormatInfo
Public Shared Function GetInstance (provider As IFormatProvider) As DateTimeFormatInfo

參數

provider
IFormatProvider

IFormatProvider,此提供者會取得 DateTimeFormatInfo 物件。The IFormatProvider that gets the DateTimeFormatInfo object.

-或--or- 若要取得null ,則為 CurrentInfonull to get CurrentInfo.

傳回

DateTimeFormatInfo 相關聯的 IFormatProvider 物件。A DateTimeFormatInfo object associated with IFormatProvider.

備註

這個方法會使用IFormatProvider.GetFormatDateTimeFormatInfo物件formatProvider做為Type參數的方法。This method uses the IFormatProvider.GetFormat method of formatProvider using an DateTimeFormatInfo object as the Type parameter. 如果formatProvider IFormatProvider.GetFormat CurrentInfonull ,或如果傳回,這個null方法會傳回。If formatProvider is null or if IFormatProvider.GetFormat returns null, this method returns CurrentInfo.

您的應用程式可以DateTimeFormatInfo使用下列其中一種方法,取得特定文化特性的物件:Your application can get a DateTimeFormatInfo object for a specific culture using one of the following methods:

DateTimeFormatInfo物件只能針對不因文化特性而異,或針對特定文化特性而建立,而不是針對中性文化特性。A DateTimeFormatInfo object can be created only for the invariant culture or for specific cultures, not for neutral cultures.

如需不因文化特性、特定文化特性和中性文化特性的詳細資訊CultureInfo ,請參閱類別描述。For more information about the invariant culture, specific cultures, and neutral cultures, see the CultureInfo class description.

適用於

另請參閱