TypeConverter.CreateInstance 方法

定義

重新建立 Object,需為物件提供一組屬性值。

多載

CreateInstance(ITypeDescriptorContext, IDictionary)

使用指定的內容,建立與這個 TypeConverter 相關聯之類型的執行個體,並為物件提供一組屬性值。

CreateInstance(IDictionary)

重新建立 Object,需為物件提供一組屬性值。

CreateInstance(ITypeDescriptorContext, IDictionary)

使用指定的內容,建立與這個 TypeConverter 相關聯之類型的執行個體,並為物件提供一組屬性值。

public:
 virtual System::Object ^ CreateInstance(System::ComponentModel::ITypeDescriptorContext ^ context, System::Collections::IDictionary ^ propertyValues);
public virtual object CreateInstance (System.ComponentModel.ITypeDescriptorContext context, System.Collections.IDictionary propertyValues);
public virtual object? CreateInstance (System.ComponentModel.ITypeDescriptorContext? context, System.Collections.IDictionary propertyValues);
abstract member CreateInstance : System.ComponentModel.ITypeDescriptorContext * System.Collections.IDictionary -> obj
override this.CreateInstance : System.ComponentModel.ITypeDescriptorContext * System.Collections.IDictionary -> obj
Public Overridable Function CreateInstance (context As ITypeDescriptorContext, propertyValues As IDictionary) As Object

參數

context
ITypeDescriptorContext

提供格式內容的 ITypeDescriptorContext

propertyValues
IDictionary

新屬性值的 IDictionary

傳回

Object

代表指定 IDictionaryObject;如果無法建立物件,則為 null。 這個方法一律會傳回 null

備註

針對不可變但您想要提供可變更屬性的物件,請使用這個方法。

給繼承者的注意事項

如果您想要轉換的類型必須重新建立物件以變更其值,請覆寫這個方法。

context 參數可以用於擷取環境的其他資訊,而這個轉換子就是從該環境叫用的。 此參數可以是 null ,因此請一律檢查它。 甚至,內容物件上的屬性可能會傳回 null

參數所提供的 propertyValues 字典有一系列的名稱/值組,每個屬性各有一個。 GetProperties(Object)

另請參閱

適用於

CreateInstance(IDictionary)

重新建立 Object,需為物件提供一組屬性值。

public:
 System::Object ^ CreateInstance(System::Collections::IDictionary ^ propertyValues);
public object CreateInstance (System.Collections.IDictionary propertyValues);
public object? CreateInstance (System.Collections.IDictionary propertyValues);
member this.CreateInstance : System.Collections.IDictionary -> obj
Public Function CreateInstance (propertyValues As IDictionary) As Object

參數

propertyValues
IDictionary

IDictionary,表示新屬性值的字典。

傳回

Object

代表指定 IDictionaryObject;如果無法建立物件,則為 null。 這個方法一律會傳回 null

備註

針對不可變但您想要提供可變更屬性的物件,請使用這個方法。

參數所提供的 propertyValues 字典有一系列的名稱/值組,每個屬性各有一個。 GetProperties

另請參閱

適用於