Share via


StringExtensions.As Method

Definition

Overloads

As<TValue>(String)

Converts a string to a strongly typed value of the specified data type.

As<TValue>(String, TValue)

Converts a string to the specified data type and specifies a default value.

As<TValue>(String)

Converts a string to a strongly typed value of the specified data type.

public static TValue As<TValue> (this string value);
static member As : string -> 'Value
<Extension()>
Public Function As(Of TValue) (value As String) As TValue

Type Parameters

TValue

The data type to convert to.

Parameters

value
String

The value to convert.

Returns

TValue

The converted value.

Applies to

As<TValue>(String, TValue)

Converts a string to the specified data type and specifies a default value.

public static TValue As<TValue> (this string value, TValue defaultValue);
static member As : string * 'Value -> 'Value
<Extension()>
Public Function As(Of TValue) (value As String, defaultValue As TValue) As TValue

Type Parameters

TValue

The data type to convert to.

Parameters

value
String

The value to convert.

defaultValue
TValue

The value to return if value is null.

Returns

TValue

The converted value.

Applies to