Share via


StringExtensions.IsInt Method

Checks whether a string can be converted to an integer.

Namespace:  System.Web.WebPages
Assembly:  System.Web.WebPages (in System.Web.WebPages.dll)

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function IsInt ( _
    value As String _
) As Boolean
'Usage
Dim value As String 
Dim returnValue As Boolean 

returnValue = value.IsInt()
public static bool IsInt(
    this string value
)
[ExtensionAttribute]
public:
static bool IsInt(
    String^ value
)
static member IsInt : 
        value:string -> bool
public static function IsInt(
    value : String
) : boolean

Parameters

Return Value

Type: System.Boolean
true if value can be converted to the specified type; otherwise, false.

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

Before you try to convert, you can check whether the string can be converted to an integer by calling the IsInt method, which returns true if the string value can be converted.

See Also

Reference

StringExtensions Class

System.Web.WebPages Namespace