StringExtensions.As<TValue> Method (String, TValue)
Converts a string to the specified data type and specifies a default value.
Namespace: System.Web.WebPages
Assembly: System.Web.WebPages (in System.Web.WebPages.dll)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function As(Of TValue) ( _
value As String, _
defaultValue As TValue _
) As TValue
'Usage
Dim value As String
Dim defaultValue As TValue
Dim returnValue As TValue
returnValue = value.As(defaultValue)
public static TValue As<TValue>(
this string value,
TValue defaultValue
)
[ExtensionAttribute]
public:
generic<typename TValue>
static TValue As(
String^ value,
TValue defaultValue
)
static member As :
value:string *
defaultValue:'TValue -> 'TValue
JScript does not support generic types and methods.
Type Parameters
- TValue
The data type to convert to.
Parameters
- value
Type: System.String
The value to convert.
- defaultValue
Type: TValue
The value to return if value is null reference (Nothing in Visual Basic).
Return Value
Type: TValue
The converted value.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=vs.111) or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.111).
Remarks
For more information about how to use this method, see the As() topic.