Прочетете на английски Редактиране

Споделяне чрез


TypeConverter.ConvertFromInvariantString Method

Definition

Converts the value to a type of this converter, using the invariant culture.

Overloads

ConvertFromInvariantString(String)

Converts the given string to the type of this converter, using the invariant culture.

ConvertFromInvariantString(ITypeDescriptorContext, String)

Converts the given string to the type of this converter, using the invariant culture and the specified context.

ConvertFromInvariantString(String)

Source:
TypeConverter.cs
Source:
TypeConverter.cs
Source:
TypeConverter.cs

Converts the given string to the type of this converter, using the invariant culture.

C#
public object? ConvertFromInvariantString(string text);
C#
public object ConvertFromInvariantString(string text);

Parameters

text
String

The String to convert.

Returns

An Object that represents the converted text.

Exceptions

The conversion cannot be performed.

Remarks

The default implementation always returns null.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ConvertFromInvariantString(ITypeDescriptorContext, String)

Source:
TypeConverter.cs
Source:
TypeConverter.cs
Source:
TypeConverter.cs

Converts the given string to the type of this converter, using the invariant culture and the specified context.

C#
public object? ConvertFromInvariantString(System.ComponentModel.ITypeDescriptorContext? context, string text);
C#
public object ConvertFromInvariantString(System.ComponentModel.ITypeDescriptorContext context, string text);

Parameters

context
ITypeDescriptorContext

An ITypeDescriptorContext that provides a format context.

text
String

The String to convert.

Returns

An Object that represents the converted text.

Exceptions

The conversion cannot be performed.

Remarks

An exception is raised if the string cannot be converted into the appropriate object. The default implementation always returns null.

Use the context parameter to extract additional information about the environment from which this converter is invoked. This parameter can be null, so always check it. Also, properties on the context object can return null.

See also

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1