下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、-摘自 ChinaAsp 网络 (文 /讨饭猫 )ASP+内置支持 3种语言:C#, Visual Basic (注意不是 VBScript ), JScript。下面列出一个简 单的C#和VB语法对照表,看看你到底喜欢那个?C# 语法VB 语法定义变量int x;String s;String s1, s2;Object o;Object obj = new Object(); public String name;Dim x As IntegerDim s As StringDim s1, s2 As StringDim o 'Implicitly Object Dim obj A
2、s New Object()Public name As String输出内容Response.Write("foo");注释/ This is a comment/* This is a multi-line comment */读取数据集合数组String s=Request.QueryString"Name"String value=Request.Cookies"key"定义简单数据集public String name get return .;set . = value; Response.Write("foo&
3、quot;)' This is a comment' This' isa' multi-line' commentDim s, value As Strings = Request.QueryString("Name") value = Request.Cookies("Key").Value 'Note that default non-indexed properties'must be explicitly named in VBPublic Property Name As StringGe
4、tReturn.;End GetSet. = Value;End PropertyEnd Property数组Dim a(3) As Stringa(0) = "1"a(1) = "2"a(2) = "3"Dim a(3,3) As Stringa(0,0) = "1"a(1,0) = "2"a(2,0) = "3"String a = new String3; a0 = "1"a1 = "2"a2 = "3"Str
5、ing a = new String33; a00 = "1"a10 = "2"a20 = "3"Array of unspecified bounds (NA in C#)Dim a() As String a(0,0) = "1" a(1,0) = "2" a(2,0) = "3" Dim a(,) As Stringa(0,0) = "1" a(1,0) = "2" a(2,0) = "3"初始化变量Dim s
6、 As String = "Hello World"Dim i As Integer = 1Dim a() As Double = 3.00, 4.00, 5.00 String s = "Hello World" int i = 1 double a = 3.00, 4.00, 5.00 ; If 结构if (Request.QueryString != null) If Not (Request.QueryString = Null)End IfCase 结构switch (FirstName) case "John" :brea
7、k;case "Paul" :Select (FirstName) case "John" :case "Paul" :break;case "Ringo"break;For循环for (int i=0; i<3; i+) a(i) = "test"While循环int i = 0;while (i<3) Co nsole.WriteLi ne(i.ToStri ng();i += 1;字符串操作Stri ng s1;Stri ng s2 = "hello" s2
8、 += " world"s1 = s2 + " !"Dim I As In teger I = 0 Do While IDim s1, s2 As Stri ng s2 = "hello" s2 &= " world"s1 = s2 & " !"事件处理void MyButton_Click(Object sen der, Even tArgs E) Sub MyButton_Click(Se nder As Object, E As Even tArgs)End Sub注意By
9、Val在VB中是省缺参数对象操作MyObject obj = (MyObject)Session"Some Value"IMyObject iObj = objDim bj As MyObjectDim iObj As IMyObject obj = Session("Some Value") iObj = CType(obj, IMyObject)Dim i As In tegerDim s As Stri ngDim d As Doublei = 3s = i.ToStri ng()类型转换int i = 3;String s = i.ToStrin
10、g(); double d = Double.Parse(s);类定义和继承using System; namespace MySpace public class Foo : Bar int x;public Foo() x = 4; public void Add(int x) this.x += x; public int GetNum() return x; / csc /out:librarycs.dll /t:library library.csImports System Namespace MySpace Public Class Foo : Inherits Bar Dim x As IntegerPublic Sub New() MyBase.New() x = 4 End SubPublic Sub Add(x As Integer)Me.x = Me.x + x End Sub Public Function GetNum() As Integer Return x End Function End Class End Namespace ' v
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2022北京中考数学二模分类汇编《代数综合》含答案解析
- 社群变现课程设计
- 认知系统 亲子课程设计
- 师范技能课程设计
- 深深浅浅话友谊课程设计
- 简易发生器课程设计
- 《工程概预算》课程设计
- 福建师范大学《笔译(1)》2022-2023学年第一学期期末试卷
- 成都中医药大学《眼科护理学》2022-2023学年第一学期期末试卷
- 寄小读者的读书笔记
- 屋面防水动火安全方案
- 红色扁平风音乐节音乐会动态模板课件
- 光州事件与韩国的民主化课件
- 临时用电系统图
- 个体化健康教育
- YY∕T 0296-2022 一次性使用注射针 识别色标
- 红楼梦服饰文化析课件
- 初中生心理健康主题班会课件ppt
- PMC生产计划与物料控制实务课件
- 初中英语单词表大全必背个带音标
- 还原糖实验-ppt课件
评论
0/150
提交评论