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:

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

ASP.NET Razor - C# Variables的更多相关文章

  1. ASP.NET Razor——Razor 简介

    ASP.NET Razor - 标记 Razor 不是一种编程语言.它是服务器端的标记语言. 什么是 Razor? Razor 是一种标记语法,可以让您将基于服务器的代码(Visual Basic 和 ...

  2. ASP.NET Razor 视图引擎编程参考

    ASP.NET Razor 视图引擎编程参考   转载请注明出处:http://surfsky.cnblogs.com Rasor 视图引擎    http://msdn.microsoft.com/ ...

  3. ASP.NET Razor - 标记

    目录 什么是 Razor? Razor 帮助器 ASP.NET Razor - C# 和 VB 代码语法 主要的 Razor C# 语法规则 它是如何工作的? 使用对象 If 和 Else条件 读取用 ...

  4. ASP.NET Razor C# 和 VB 代码语法

    ylbtech-.NET: ASP.NET Razor  C# 和 VB 代码语法 Razor 不是一种编程语言.它是服务器端的标记语言. 1. C# 和 VB 代码语法返回顶部 Razor 同时支持 ...

  5. ASP.NET Razor 简介

    ylbtech-.NET: ASP.NET Razor 简介 Razor 不是一种编程语言.它是服务器端的标记语言. 1. 什么是 Razor?返回顶部 Razor 是一种标记语法,可以让您将基于服务 ...

  6. ASP.NET Razor - C# and VB Code Syntax

    http://www.w3schools.com/aspnet/razor_syntax.asp Razor supports both C# (C sharp) and VB (Visual Bas ...

  7. ASP.NET Razor——ASP.NET Razor - C#代码语法

    Razor 同时支持 C# (C sharp) 和 VB (Visual Basic). 主要的 Razor C# 语法规则 Razor 代码块包含在 @{ ... } 中 内联表达式(变量和函数)以 ...

  8. ASP.NET Razor

    一.为什么要学习Razor? 可以让服务器代码(就是c#和vb)嵌入到网页中,也就是说这个页面中包含html代码和C#(vb)代码.基于服务器的代码可以在网页传送给浏览器时,创建动态 Web 内容.当 ...

  9. 基础知识:什么是ASP.NET Razor页面?

    Razor页面与ASP.NET MVC开发使用的视图组件非常相似,它们具有所有相同的语法和功能. 最关键的区别是模型和控制器代码也包含在Razor页面中.它更像是一个MVVM(Model-View-V ...

随机推荐

  1. Oracle 生成数据字典

    SELECT ROWNUM 序号,A.COLUMN_NAME AS "字段名称",B.comments AS "字段描述", A.DATA_TYPE as 字段 ...

  2. set statistics profile on实例

    set statistics profile on实例 1.SQL语句实例   SQL 代码   复制 SET STATISTICS PROFILE ON GO SELECT COUNT(b.[Sal ...

  3. C++编译错误fatal error C1004: 发现意外的文件尾

    出现这种情况就是类或者结构体的定义后面没有加“;”导致的. 而且这种问题好难排查.

  4. dubbo之直连提供者

    在开发及测试环境下,经常需要绕过注册中心,只测试指定服务提供者,这时候可能需要点对点直连,点对点直联方式,将以服务接口为单位,忽略注册中心的提供者列表,A 接口配置点对点,不影响 B 接口从注册中心获 ...

  5. QT-Creator+SDK+编译器+自定义配置

    QT4.8的软件曾经耗费巨大的功夫进行构建,不舍得扔掉!重新安装Qt4.8版本 1.安装qt-creator 安装qt-creator-win-opensource-2.4.0.exe版本,不建议使用 ...

  6. react构建前端项目方法汇总

    react简介: 一.使用react 创建一个PC端的项目 (a):使用 yemon 创建一个 webpack 的 react 的项目 控制台安装并且产看 yemon 的版本 yo -v (b): 全 ...

  7. socket主要函数介绍

    1.   基本套接字函数(1)socket函数原型 socket(建立一个socket文件描述符) 所需头文件 #include <sys/types.h> #include <sy ...

  8. day8 面向对象编程基础

    活在当下的程序员应该都听过“面向对象编程”一词,也经常有人问能不能用一句话解释下什么是“面向对象编程”,我们先来看看比较正式的说法. 把一组数据结构和处理它们的方法组成对象(object),把相同行为 ...

  9. Lua的热更新学习笔记_01

    热更新的的实现方式 1.使用lua脚本编写游戏的UI或者其他的逻辑 2.使用C#的反射技术 3.使用C#Light AssetBundle是什么? 1.unity提供一个资源更新技术,就是通过Asse ...

  10. Node.js+Protractor+vscode搭建测试环境(1)

    1.protractor简介 官网地址:http://www.protractortest.org/ Protractor是一个end-to-end的测试框架,从网络上得到的答案是Protractor ...