TypeDescriptor.GetConverter 方法

定义

返回组件或类型的类型转换器。Returns a type converter for a component or a type.

重载

GetConverter(Object)

返回指定组件类型的类型转换器。Returns a type converter for the type of the specified component.

GetConverter(Type)

返回指定类型的类型转换器。Returns a type converter for the specified type.

GetConverter(Object, Boolean)

为具有自定义类型描述符的指定组件类型返回一个类型转换器。Returns a type converter for the type of the specified component with a custom type descriptor.

GetConverter(Object)

返回指定组件类型的类型转换器。Returns a type converter for the type of the specified component.

public:
 static System::ComponentModel::TypeConverter ^ GetConverter(System::Object ^ component);
public static System.ComponentModel.TypeConverter GetConverter (object component);
static member GetConverter : obj -> System.ComponentModel.TypeConverter
Public Shared Function GetConverter (component As Object) As TypeConverter

参数

component
Object

要为其获取转换器的组件。A component to get the converter for.

返回

TypeConverter

指定组件的 TypeConverterA TypeConverter for the specified component.

例外

componentnullcomponent is null.

component 是一个跨进程进行远程处理的对象。component is a cross-process remoted object.

示例

有关使用此方法的示例,请参阅 TypeConverter 类。For an example of using this method, see the TypeConverter class.

注解

此方法通过查找来查找适当的类型转换器 TypeConverterAttributeThis method locates an appropriate type converter by looking for a TypeConverterAttribute. 如果找不到 TypeConverterAttribute ,它将遍历类的基类层次结构,直到它找到基元类型。If it cannot find a TypeConverterAttribute, it traverses the base class hierarchy of the class until it finds a primitive type.

此方法等效于 GetConverter 带有的第二个参数的重载方法 falseThis method is equivalent to the overloaded GetConverter method with a second parameter of false.

另请参阅

适用于

GetConverter(Type)

返回指定类型的类型转换器。Returns a type converter for the specified type.

public:
 static System::ComponentModel::TypeConverter ^ GetConverter(Type ^ type);
public static System.ComponentModel.TypeConverter GetConverter (Type type);
static member GetConverter : Type -> System.ComponentModel.TypeConverter
Public Shared Function GetConverter (type As Type) As TypeConverter

参数

type
Type

目标组件的 TypeThe Type of the target component.

返回

TypeConverter

指定类型的 TypeConverterA TypeConverter for the specified type.

例外

typenulltype is null.

注解

仅当没有对象的实例时,才调用此方法的此版本。Call this version of this method only when you do not have an instance of the object.

此方法通过查找来查找适当的类型转换器 TypeConverterAttributeThis method looks for the appropriate type converter by looking for a TypeConverterAttribute. 如果找不到 TypeConverterAttribute ,它将遍历类的基类层次结构,直到它找到基元类型。If it cannot find a TypeConverterAttribute, it traverses the base class hierarchy of the class until it finds a primitive type.

另请参阅

适用于

GetConverter(Object, Boolean)

为具有自定义类型描述符的指定组件类型返回一个类型转换器。Returns a type converter for the type of the specified component with a custom type descriptor.

public:
 static System::ComponentModel::TypeConverter ^ GetConverter(System::Object ^ component, bool noCustomTypeDesc);
public static System.ComponentModel.TypeConverter GetConverter (object component, bool noCustomTypeDesc);
static member GetConverter : obj * bool -> System.ComponentModel.TypeConverter
Public Shared Function GetConverter (component As Object, noCustomTypeDesc As Boolean) As TypeConverter

参数

component
Object

要为其获取转换器的组件。A component to get the converter for.

noCustomTypeDesc
Boolean

如果为 true,则考虑自定义类型描述信息;否则为 falsetrue to consider custom type description information; otherwise, false.

返回

TypeConverter

指定组件的 TypeConverterA TypeConverter for the specified component.

例外

componentnullcomponent is null.

component 是一个跨进程进行远程处理的对象。component is a cross-process remoted object.

注解

此方法通过尝试查找来查找适当的类型转换器 TypeConverterAttributeThis method looks for the appropriate type converter by trying to find a TypeConverterAttribute. 如果找不到 TypeConverterAttribute ,它将遍历类的基类层次结构,直到它找到基元类型。If it cannot find a TypeConverterAttribute, it traverses the base class hierarchy of the class until it finds a primitive type.

另请参阅

适用于