TypeConverter.ConvertToString TypeConverter.ConvertToString TypeConverter.ConvertToString TypeConverter.ConvertToString Method

定义

将指定值转换为字符串表示形式。Converts the specified value to a string representation.

重载

ConvertToString(ITypeDescriptorContext, CultureInfo, Object) ConvertToString(ITypeDescriptorContext, CultureInfo, Object) ConvertToString(ITypeDescriptorContext, CultureInfo, Object) ConvertToString(ITypeDescriptorContext, CultureInfo, Object)

使用指定的上下文和区域性信息将给定的值转换为字符串表示形式。Converts the given value to a string representation, using the specified context and culture information.

ConvertToString(Object) ConvertToString(Object) ConvertToString(Object) ConvertToString(Object)

将指定值转换为字符串表示形式。Converts the specified value to a string representation.

ConvertToString(ITypeDescriptorContext, Object) ConvertToString(ITypeDescriptorContext, Object) ConvertToString(ITypeDescriptorContext, Object) ConvertToString(ITypeDescriptorContext, Object)

使用给定的上下文将给定的值转换为字符串表示形式。Converts the given value to a string representation, using the given context.

ConvertToString(ITypeDescriptorContext, CultureInfo, Object) ConvertToString(ITypeDescriptorContext, CultureInfo, Object) ConvertToString(ITypeDescriptorContext, CultureInfo, Object) ConvertToString(ITypeDescriptorContext, CultureInfo, Object)

使用指定的上下文和区域性信息将给定的值转换为字符串表示形式。Converts the given value to a string representation, using the specified context and culture information.

public:
 System::String ^ ConvertToString(System::ComponentModel::ITypeDescriptorContext ^ context, System::Globalization::CultureInfo ^ culture, System::Object ^ value);
public string ConvertToString (System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value);
member this.ConvertToString : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj -> string
Public Function ConvertToString (context As ITypeDescriptorContext, culture As CultureInfo, value As Object) As String

参数

context
ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext

一个 ITypeDescriptorContext,用于提供格式上下文。An ITypeDescriptorContext that provides a format context.

culture
CultureInfo CultureInfo CultureInfo CultureInfo

CultureInfoA CultureInfo. 如果传递 null,则采用当前区域性。If null is passed, the current culture is assumed.

value
Object Object Object Object

要转换的 ObjectThe Object to convert.

返回

一个 Object,它表示转换后的值。An Object that represents the converted value.

异常

无法执行转换。The conversion cannot be performed.

注解

使用 context 参数提取有关调用此转换器的环境的附加信息。Use the context parameter to extract additional information about the environment from which this converter is invoked. 此参数可以是null,因此总是需要检查。This parameter can be null, so always check it. 同样,上下文对象的属性可以返回 nullAlso, properties on the context object can return null.

具体取决于值格式化程序的实现,它可以将传递回要重新创建对象的实例的值格式化程序返回的字符串。Depending on the implementation of the value formatter, it might be possible to pass the returned string back into the value formatter to re-create an instance of the object.

另请参阅

ConvertToString(Object) ConvertToString(Object) ConvertToString(Object) ConvertToString(Object)

将指定值转换为字符串表示形式。Converts the specified value to a string representation.

public:
 System::String ^ ConvertToString(System::Object ^ value);
public string ConvertToString (object value);
member this.ConvertToString : obj -> string
Public Function ConvertToString (value As Object) As String

参数

value
Object Object Object Object

要转换的 ObjectThe Object to convert.

返回

一个 Object,它表示转换后的值。An Object that represents the converted value.

异常

无法执行转换。The conversion cannot be performed.

示例

此函数的示例,请参阅TypeConverter类。For an example on this function, see the TypeConverter class.

注解

具体取决于值格式化程序的实现,它可以将传递回要重新创建对象的实例的值格式化程序返回的字符串。Depending on the implementation of the value formatter, it might be possible to pass the returned string back into the value formatter to re-create an instance of the object.

ConvertToString(ITypeDescriptorContext, Object) ConvertToString(ITypeDescriptorContext, Object) ConvertToString(ITypeDescriptorContext, Object) ConvertToString(ITypeDescriptorContext, Object)

使用给定的上下文将给定的值转换为字符串表示形式。Converts the given value to a string representation, using the given context.

public:
 System::String ^ ConvertToString(System::ComponentModel::ITypeDescriptorContext ^ context, System::Object ^ value);
public string ConvertToString (System.ComponentModel.ITypeDescriptorContext context, object value);
member this.ConvertToString : System.ComponentModel.ITypeDescriptorContext * obj -> string
Public Function ConvertToString (context As ITypeDescriptorContext, value As Object) As String

参数

context
ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext ITypeDescriptorContext

一个 ITypeDescriptorContext,用于提供格式上下文。An ITypeDescriptorContext that provides a format context.

value
Object Object Object Object

要转换的 ObjectThe Object to convert.

返回

一个 Object,它表示转换后的值。An Object that represents the converted value.

异常

无法执行转换。The conversion cannot be performed.

注解

使用 context 参数提取有关调用此转换器的环境的附加信息。Use the context parameter to extract additional information about the environment from which this converter is invoked. 此参数可以是null,因此总是需要检查。This parameter can be null, so always check it. 同样,上下文对象的属性可以返回 nullAlso, properties on the context object can return null.

具体取决于值格式化程序的实现,它可以将传递回要重新创建对象的实例的值格式化程序返回的字符串。Depending on the implementation of the value formatter, it might be possible to pass the returned string back into the value formatter to re-create an instance of the object.

另请参阅

适用于