📄 asp+ 支持的 c# 和 vb 语法对照表.htm
字号:
Forms</A><BR>·<A
href="http://lzjx.com/w/main.asp?id=548&sx=jc">ASP+中文显示之两种解决方法</A><BR>·<A
href="http://lzjx.com/w/main.asp?id=441&sx=jc">ASP上手“快捷方式”-序言</A><BR>·<A
title=ASP上手“快捷方式”-剖析ASP脚本
href="http://lzjx.com/w/main.asp?id=442&sx=jc">ASP上手“快捷方式”-剖析..</A><BR>·<A
title=ASP上手“快捷方式”-对象和组件
href="http://lzjx.com/w/main.asp?id=443&sx=jc">ASP上手“快捷方式”-对象..</A><BR>·<A
title=ASP上手“快捷方式”-脚本示例
href="http://lzjx.com/w/main.asp?id=444&sx=jc">ASP上手“快捷方式”-脚本..</A><BR>·<A
title=ASP上手“快捷方式”-脚本编写技巧
href="http://lzjx.com/w/main.asp?id=445&sx=jc">ASP上手“快捷方式”-脚本..</A><BR>·<A
title=ASP上手“快捷方式”-样例脚本
href="http://lzjx.com/w/main.asp?id=446&sx=jc">ASP上手“快捷方式”-样例..</A><BR>·<A
title=ASP上手“快捷方式”-数据库
href="http://lzjx.com/w/main.asp?id=447&sx=jc">ASP上手“快捷方式”-数据..</A><BR>·<A
href="http://lzjx.com/w/main.asp?id=523&sx=jc">ASP的技术特点与使用方法</A><BR>·<A
href="http://lzjx.com/w/main.asp?id=522&sx=jc">SQL
Server访问ADO</A><BR>·<A
href="http://lzjx.com/w/main.asp?id=521&sx=jc">ASP个人上手指南</A><BR></TD></TR></TBODY></TABLE><SPAN
class=l15></SPAN></TD>
<TD vAlign=top align=middle width=1 bgColor=#cccccc></TD>
<TD vAlign=top align=middle width=592 bgColor=#ffffff>
<TABLE cellSpacing=0 cellPadding=6 width="98%" border=0>
<TBODY>
<TR>
<TD class=xx vAlign=bottom height=30>■ 基础教程 > ASP+ 支持的 C# 和 VB
语法对照表</TD></TR></TBODY></TABLE>
<TABLE height=119 cellSpacing=6 cellPadding=3 width="99%" border=0>
<TBODY>
<TR>
<TD class=xk vAlign=top align=left
width="50%">---摘自《ChinaAsp网络》(文/讨饭猫)<BR>ASP+内置支持3种语言:C#,Visual
Basic(注意不是VBScript),JScript。下面列出一个简单的C#和VB语法对照表,看看你到底喜欢那个?<BR>C#
语法 VB 语法 <BR><BR>定义变量 <BR>int x; Dim x
As Integer <BR>String s; Dim s As String <BR>String
s1, s2; Dim s1, s2 As String <BR>Object
o; Dim o 'Implicitly Object <BR>Object obj = new
Object(); Dim obj As New Object() <BR>public String
name; Public name As String <BR><BR>输出内容
<BR><BR>Response.Write("foo"); Response.Write("foo") <BR><BR><BR>注释
<BR><BR> ' This is a
comment<BR> ' This <BR>// This is a
comment ' is<BR>/* This is a multi-line comment */ '
a <BR> ' multi-line<BR> '
comment <BR><BR>读取数据集合数组 <BR><BR> Dim s, value As
String <BR> s = Request.QueryString("Name")
<BR>String s=Request.QueryString["Name"]; value =
Request.Cookies("Key").Value<BR>String
value=Request.Cookies["key"]; 'Note that default non-indexed
properties<BR> 'must be explicitly named in
VB <BR><BR><BR>定义简单数据集 <BR><BR>public String name { <BR>get {<BR>...
<BR>return ...; <BR>} <BR>set {<BR>... = value;
<BR>}<BR>} <BR> Public Property Name As
String<BR> Get <BR> ...
<BR> Return<BR> ...;
<BR> End
Get<BR> Set<BR> ... = Value;
<BR> End Set <BR> End
Property <BR><BR>数组 <BR><BR>String[] a = new String[3]; <BR>a[0] =
"1"; <BR>a[1] = "2"; <BR>a[2] = "3<BR>String[][] a = new
String[3][3]; <BR>a[0][0] = "1"; <BR>a[1][0] = "2"; <BR>a[2][0] =
"3"; <BR>Dim a(3) As String <BR>a(0) = "1" <BR>a(1) = "2" <BR>a(2) =
"3" <BR>Dim a(3,3) As String <BR>a(0,0) = "1" <BR>a(1,0) = "2"
<BR>a(2,0) = "3"<BR> ' Array of unspecified bounds
(NA in C#) <BR> Dim a() As String
<BR> a(0,0) = "1" <BR> a(1,0) = "2"
<BR> a(2,0) = "3" <BR> Dim a(,) As
String <BR> a(0,0) = "1" <BR> a(1,0) =
"2" <BR> a(2,0) = "3" <BR><BR>初始化变量 <BR><BR>String s
= "Hello World"; <BR>int i = 1 <BR>double[] a = { 3.00, 4.00, 5.00
}; <BR> Dim s As String = "Hello World"
<BR> Dim i As Integer = 1 <BR> Dim
a() As Double = { 3.00, 4.00, 5.00 } <BR><BR>If 结构 <BR><BR>if
(Request.QueryString != null) {<BR>... <BR>} <BR>
If Not (Request.QueryString = Null)<BR> ...
<BR> End If <BR><BR>Case 结构 <BR><BR>switch
(FirstName){<BR>case "John" :<BR>... <BR>break; <BR>case "Paul" :
<BR>... <BR>break; <BR>case "Ringo" : <BR>... <BR>break;
<BR>} <BR> Select
(FirstName)<BR> case "John"
:<BR> ... <BR> case "Paul"
:<BR> ...<BR> case "Ringo"
:<BR> ...<BR> End
Select <BR><BR>For 循环 <BR><BR>for (int i=0; i<3; i++)<BR>a(i) =
"test"; <BR> Dim I As
Integer<BR> For I = 0 To
2<BR> a(I) =
"test"<BR> Next <BR><BR>While 循环 <BR><BR>int i = 0;
<BR>while (i<3) {<BR>Console.WriteLine(i.ToString());<BR>i +=
1;<BR>} <BR> Dim I As
Integer<BR> I = 0 Do While I <BR><BR>字符串操作
<BR><BR>String s1; <BR>String s2 = "hello"; <BR>s2 += " world";
<BR>s1 = s2 + " !!!"; <BR> Dim s1, s2 As String
<BR> s2 = "hello" <BR> s2 &= "
world" <BR> s1 = s2 & " !!!" <BR><BR>事件处理
<BR><BR>void MyButton_Click(Object sender, EventArgs E) {<BR>...
<BR>} <BR> Sub MyButton_Click(Sender As Object, E As
EventArgs)<BR> ... <BR> End Sub<BR> 注意
ByVal 在VB中是省缺参数 <BR><BR>对象操作 <BR><BR>MyObject obj =
(MyObject)Session["Some Value"];<BR>IMyObject iObj =
obj <BR> Dim bj As MyObject
<BR> Dim iObj As IMyObject
<BR> obj = Session("Some Value")
<BR> iObj = CType(obj, IMyObject) <BR><BR>类型转换
<BR><BR>int i = 3; <BR>String s = i.ToString(); <BR>double d =
Double.Parse(s); <BR> Dim i As Integer
<BR> Dim s As String <BR> Dim d As
Double <BR> i = 3 <BR> s =
i.ToString() <BR> d =
CDbl(s)<BR> ' 参见 CDbl(...), CStr(...),
... <BR><BR>类定义和继承 <BR><BR>using System; <BR>namespace MySpace
{<BR>public class Foo : Bar {<BR>int x; <BR>public Foo() {x = 4; }
<BR>public void Add(int x) { this.x += x; } <BR>public int GetNum()
{ return x; } <BR>} <BR>}<BR>// csc /out:librarycs.dll /t:library
library.cs <BR> Imports System
<BR> Namespace MySpace <BR> Public
Class Foo : Inherits Bar <BR> Dim x As Integer
<BR><BR> Public Sub New()
<BR> MyBase.New() <BR> x = 4
<BR> End Sub <BR> Public Sub Add(x
As Integer) <BR> Me.x = Me.x + x
<BR> End Sub <BR> Public Function
GetNum() As Integer <BR> Return x
<BR> End Function <BR> End Class
<BR> End Namespace <BR> ' vbc
/out:libraryvb.dll /t:library
library.vb <BR><BR>(也许是多年来用惯了C的缘故,一直喜欢C那种简练,个性化的风格,文字和符号混合使用,可以让眼睛迅速找到关键所在,避免视线被淹没在复杂的字符串中,所以即使在
ASP 时代,也是坚持使用风格类似的
JScript,现在终于……hehehe…..-讨饭猫)<BR></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
<TBODY>
<TR>
<TD>■今日推荐:<A
href="http://lzjx.com/w/main.asp?id=388&sx=jc">ASP内建对象Serv</A>
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=800 bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD
background="ASP+ 支持的 C# 和 VB 语法对照表.files/qw39.gif"></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=1 cellPadding=5 width=800 bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD class=N noWrap align=middle>
<TABLE cellSpacing=0 cellPadding=0 width="100%" bgColor=#ffffff
border=0><TBODY>
<TR>
<TD
background="ASP+ 支持的 C# 和 VB 语法对照表.files/qw39.gif"></TD></TR></TBODY></TABLE><BR>本网站是学习网站,内容整理大多来自互联网,尽量标明了出处,如果侵犯了您的权力请通知我,立即纠正<BR>欢迎提出宝贵建议,提供相关资料,以便相互学习,共同提高!<BR>
<OBJECT
codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0
height=18 width=103 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="BGCOLOR" VALUE=""><PARAM NAME="movie" VALUE="../images/21sg.swf"><PARAM NAME="quality" VALUE="high">
<embed src="../images/21sg.swf"
quality="high"
pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width="103" height="18" ></embed>
</OBJECT></TD></TR>
<TR>
<TD height=79> </TD></TR>
<TR>
<TD align=middle></TD></TR></TBODY></TABLE></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -