TypeConverter.ConvertFromString TypeConverter.ConvertFromString TypeConverter.ConvertFromString TypeConverter.ConvertFromString Method

定義

會將指定的文字轉換成物件。Converts the specified text to an object.

多載

ConvertFromString(ITypeDescriptorContext, CultureInfo, String) ConvertFromString(ITypeDescriptorContext, CultureInfo, String) ConvertFromString(ITypeDescriptorContext, CultureInfo, String) ConvertFromString(ITypeDescriptorContext, CultureInfo, String)

會使用指定內容和文化特性資訊,將指定文字轉換為物件。Converts the given text to an object, using the specified context and culture information.

ConvertFromString(String) ConvertFromString(String) ConvertFromString(String) ConvertFromString(String)

會將指定的文字轉換成物件。Converts the specified text to an object.

ConvertFromString(ITypeDescriptorContext, String) ConvertFromString(ITypeDescriptorContext, String) ConvertFromString(ITypeDescriptorContext, String) ConvertFromString(ITypeDescriptorContext, String)

會使用指定的內容,將指定文字轉換為物件。Converts the given text to an object, using the specified context.

ConvertFromString(ITypeDescriptorContext, CultureInfo, String) ConvertFromString(ITypeDescriptorContext, CultureInfo, String) ConvertFromString(ITypeDescriptorContext, CultureInfo, String) ConvertFromString(ITypeDescriptorContext, CultureInfo, String)

會使用指定內容和文化特性資訊,將指定文字轉換為物件。Converts the given text to an object, using the specified context and culture information.

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

參數

culture
CultureInfo CultureInfo CultureInfo CultureInfo

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

text
String String String String

要進行轉換的 StringThe String to convert.

傳回

表示轉換文字的 ObjectAn Object that represents the converted text.

例外狀況

無法執行轉換作業。The conversion cannot be performed.

備註

如果字串無法轉換成適當的物件,會引發例外狀況。An exception is raised if the string cannot be converted into the appropriate object. 預設的實作 (Implementation) 一定會傳回 nullThe default implementation always returns null.

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.

另請參閱

ConvertFromString(String) ConvertFromString(String) ConvertFromString(String) ConvertFromString(String)

會將指定的文字轉換成物件。Converts the specified text to an object.

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

參數

text
String String String String

要轉換物件的文字表示。The text representation of the object to convert.

傳回

表示轉換文字的 ObjectAn Object that represents the converted text.

例外狀況

字串無法轉換為適當的物件。The string cannot be converted into the appropriate object.

範例

如需此函式的範例,請參閱TypeConverter類別。For an example of this function, see the TypeConverter class.

備註

預設的實作 (Implementation) 一定會傳回 nullThe default implementation always returns null.

ConvertFromString(ITypeDescriptorContext, String) ConvertFromString(ITypeDescriptorContext, String) ConvertFromString(ITypeDescriptorContext, String) ConvertFromString(ITypeDescriptorContext, String)

會使用指定的內容,將指定文字轉換為物件。Converts the given text to an object, using the specified context.

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

參數

text
String String String String

要進行轉換的 StringThe String to convert.

傳回

表示轉換文字的 ObjectAn Object that represents the converted text.

例外狀況

無法執行轉換作業。The conversion cannot be performed.

備註

如果字串無法轉換成適當的物件,會引發例外狀況。An exception is raised if the string cannot be converted into the appropriate object. 預設的實作 (Implementation) 一定會傳回 nullThe default implementation always returns null.

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.

另請參閱

適用於