TypeConverter.ConvertToString 方法

定義

會將指定值轉換成字串表示。Converts the specified value to a string representation.

多載

ConvertToString(ITypeDescriptorContext, CultureInfo, Object)

會使用指定的內容和文化特性資訊,將指定值轉換為字串表示。Converts the given value to a string representation, using the specified context and culture information.

ConvertToString(Object)

會將指定值轉換成字串表示。Converts the specified value to a string representation.

ConvertToString(ITypeDescriptorContext, Object)

會使用指定的內容,將指定值轉換為字串表示。Converts the given value to a string representation, using the given context.

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

提供格式內容的 ITypeDescriptorContextAn ITypeDescriptorContext that provides a format context.

culture
CultureInfo

CultureInfoA CultureInfo. 如果傳遞 null ,則會採用目前的文化特性。If null is passed, the current culture is assumed.

value
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)

會將指定值轉換成字串表示。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

要進行轉換的 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)

會使用指定的內容,將指定值轉換為字串表示。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

提供格式內容的 ITypeDescriptorContextAn ITypeDescriptorContext that provides a format context.

value
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.

另請參閱

適用於