使用JScript.NET創(chuàng)建asp.net頁(yè)面(3)
發(fā)表時(shí)間:2024-02-22 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]下面給出一個(gè)完成的函數(shù),仔細(xì)的體會(huì)一下。function getConditions(strCity : String) : String var now : Date = new Date(); switch (strCity.toUpperCase()) case "...
下面給出一個(gè)完成的函數(shù),仔細(xì)的體會(huì)一下。
function getConditions(strCity : String) : String
{
var now : Date = new Date();
switch (strCity.toUpperCase())
{
case "LONDON":
if (now.getMonth() <= 7 now.getMonth() >= 9)
{
return "overcast";
}
else
{
return "partly overcast and humid";
}
break;
case "SEATTLE":
if (now.getMonth() == 7 && now.getDay() == 4)
{
return "torrential rain";
}
else
{
return "rain";
}
break;
case "LA":
return "smoggy";
break;
case "PHOENIX":
return "damn hot";
break;
default:
return "partly cloudy with a chance of showers";
}
}
使用Jscript.net,你也可以定義其他.net架構(gòu)的類型,通過引用命名空間和派生類可以向Jscript.net引入新的數(shù)據(jù)類型。這樣在兩者的數(shù)據(jù)類型中就有可能產(chǎn)生重疊。參見下表:
Boolean .NET Framework Boolean / JScript boolean
Number .NET Framework Double / JScript number
String .NET Framework String / JScript string
Int .NET Framework Int32
Long .NET Framework Int64
Float .NET Framework Single
Double .NET Framework Double
Object .NET Framework Object / JScript Object
Date JScript Date object
Array JScript Array
Function JScript Function object