明輝手游網(wǎng)中心:是一個(gè)免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺(tái)!

使用JScript.NET創(chuàng)建asp.net頁(yè)面(3)

[摘要]下面給出一個(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