Razor引擎的转换数据类型

AsInt()

把字符串转换为整数。

if (myString.IsInt())

IsInt()

{myInt=myString.AsInt();}

AsFloat()

把字符串转换为浮点数。

if (myString.IsFloat())

IsFloat()

{myFloat=myString.AsFloat();}

AsDecimal()

把字符串转换为十进制数。

if (myString.IsDecimal())

IsDecimal()

{myDec=myString.AsDecimal();}

AsDateTime()

把字符串转换为 ASP.NET DateTime 类型

myString="10/10/2012";

IsDateTime()

myDate=myString.AsDateTime();

AsBool()

把字符串转换为逻辑值。

myString="True";

IsBool()

myBool=myString.AsBool();

ToString()

把任意数据类型转换为字符串。

myInt=1234;

myString=myInt.ToString();

原文地址:https://www.cnblogs.com/ypfnet/p/4160272.html