ASP. razor-c# Variables

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.