asp+文法介紹(一)

來源:互聯網
上載者:User

/*
*/ASP+ 現在支援兩種語言C# (簡稱 "C Sharp"), Visual Basic, and JScript.
基於習慣,在以下的語言介紹中,我們採用的練習和常式採用VB和C#語言來開發Web應用程式.如果想要得到關於.Net技術的詳細資料,請去MS的網站 查看關於 NGWS SDK!
在下面的列表中,你可以看到關於這兩種語言的文法的簡要介紹
1.變數聲名
C# 文法
int x;
String s;
String s1, s2;
Object o;
Object obj = new Object();
public String name;
VB文法
Dim x As Integer
Dim s As String
Dim s1, s2 As String
Dim o 'Implicitly Object
Dim obj As New Object()
Public name As String
2語句
C#:
Response.Write("豆腐");
VB:
Response.Write("豆腐")
3.備註陳述式
//豆腐製作,都是精品
/*
豆腐製作

都是精品
*/
VB:
'豆腐製作,都是精品
' 豆腐製作
',
'都是精品
4.獲得URL 傳遞的變數
C#:
String s = Request.QueryString["Name"];
String value = Request.Cookies["key"];
VB:
Dim s, value As String
s = Request.QueryString("Name")
value = Request.Cookies("Key").Value
5.聲明屬性
C#:
public String name {
get {
...
return ...;
}
set {
... = value;
}
}
VB:
Public Property Name As String
Get
...
Return ...;
End Get
Set
... = Value;
End Set
End Property
6.數組
C#
String[] a = new String[3];
a[0] = "1";
a[1] = "2";
a[2] = "3";
//二維數組
String[][] a = new String[3][3];
a[0][0] = "1";
a[1][0] = "2";
a[2][0] = "3";
VB:
Dim a(3) As String
a(0) = "1"
a(1) = "2"
a(2) = "3"
Dim a(3,3) As String
a(0,0) = "1"
a(1,0) = "2"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.