博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ASP.NET Razor - C# Variables
阅读量:6891 次
发布时间:2019-06-27

本文共 1121 字,大约阅读时间需要 3 分钟。

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:

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.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();

转载地址:http://hbhbl.baihongyu.com/

你可能感兴趣的文章
传递请求之职责链模式
查看>>
从 WTForm 的 URLXSS 谈开源组件的安全性
查看>>
PHP 实战之设计模式:PHP 中的设计模式
查看>>
媒体格式分析之flv -- 基于FFMPEG
查看>>
9月26日科技联播:海底捞上市首日市值破千亿;双十一前三大快递公司领头涨价...
查看>>
Python爬虫day2.2—python函数详解
查看>>
Java String.contains()方法
查看>>
学会数据库读写分离、分表分库——用Mycat,这一篇就够了!
查看>>
使用GitHub和Hexo搭建免费静态Blog
查看>>
angularjs源码分析之:angularjs执行流程
查看>>
计算型弹性裸金属服务器实例规格族 ebmc4 发布
查看>>
HTML,login文本框·
查看>>
[程序设计语言]-[核心概念]-04:数据类型
查看>>
8.8 Spring Boot静态资源处理
查看>>
从源码的角度看 React JS 中批量更新 State 的策略(上)
查看>>
马云率队夜访茅台:打造中国大数据合作的经典样板
查看>>
SOP 1.3.0 发布,开放平台解决方案项目
查看>>
中国学者世界首创:可视化“心脏芯片”问世,登Science机器人子刊论文
查看>>
为防止用户自定义Bixby按键,三星先给T-Mobile用户的S8发送更新
查看>>
在VR领域风生水起的创新企业大盘点
查看>>