TimeSpanConverter.ConvertFrom 方法

定義

將指定物件轉換為 TimeSpan

public:
 override System::Object ^ ConvertFrom(System::ComponentModel::ITypeDescriptorContext ^ context, System::Globalization::CultureInfo ^ culture, System::Object ^ value);
public override object ConvertFrom (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value);
public override object? ConvertFrom (System.ComponentModel.ITypeDescriptorContext? context, System.Globalization.CultureInfo? culture, object value);
override this.ConvertFrom : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj -> obj
Public Overrides Function ConvertFrom (context As ITypeDescriptorContext, culture As CultureInfo, value As Object) As Object

參數

context
ITypeDescriptorContext

提供格式內容的 ITypeDescriptorContext

culture
CultureInfo

選擇性 CultureInfo。 如果未提供,則會假設使用目前的文化特性。

value
Object

要進行轉換的 Object

傳回

Object,代表轉換過的值。

例外狀況

無法執行轉換作業。

value 對於目標型別並不是有效的值。

備註

這個轉換子只能將 TimeSpan 物件轉換成字串,以及從字串轉換。

可以使用 context 參數來擷取環境的其他資訊,而這個轉換子就是從這個環境叫用的。 這可能是 null,所以一定要檢查。 甚至,內容物件上的屬性可能會傳回 null

適用於

另請參閱