Http://www.w3schools.com/aspnet/razor_cs_variables.asp
Variables is named entities used to store data.
Converting Data Types
Converting from one data type to another is sometimes useful.
The most common example are to convert string input to another type, such as an integer or a date.
As a rule, user input comes as strings, even if the user entered a number. Therefore, numeric input values must is converted to numbers before they can is used in calculations.
Below is a list of common conversion methods:
| Method |
Description |
Example |
Asint () Isint () |
Converts a string to an integer. |
if (Mystring.isint ()) {Myint=mystring.asint ();} |
Asfloat () Isfloat () |
Converts a string to a floating-point number. |
if (Mystring.isfloat ()) {myfloat=mystring.asfloat ();} |
Asdecimal () Isdecimal () |
Converts a string to a decimal number. |
if (Mystring.isdecimal ()) {Mydec=mystring.asdecimal ();} |
Asdatetime () Isdatetime () |
Converts a string to an ASP. DateTime type. |
Mystring= "10/10/2012"; Mydate=mystring.asdatetime (); |
Asbool () Isbool () |
Converts a string to a Boolean. |
Mystring= "True"; Mybool=mystring.asbool (); |
| ToString () |
Converts any data type to a string. |
myint=1234; Mystring=myint.tostring (); |
ASP. razor-c# Variables