码迷,mamicode.com
首页 > Windows程序 > 详细

ASP.NET Razor - C# Variables

时间:2016-07-01 11:44:49      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:

http://www.w3schools.com/aspnet/razor_cs_variables.asp

Variables are named entities used to store data.

 

Converting Data Types

Converting from one data type to another is sometimes useful.

The most common example is 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 be converted to numbers before they can be used in calculations.

Below is a list of common conversion methods:

MethodDescriptionExample
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.NET 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.NET Razor - C# Variables

标签:

原文地址:http://www.cnblogs.com/chucklu/p/5632293.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!