下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年婴幼儿纸尿裤及成人卫生用品项目商业计划书
- T/CSES 175-2024固体废物 可提取石油烃总量的测定 红外分光光度法
- T/HNNMIA 9-2023铝用炭阳极炭碗自动填料机
- 公共停车场运营方案
- 2025年养老护理机构融资策略可行性研究报告
- 2025安全生产月口号
- 农机装备研发实施方案
- 2025年新能源太阳能产业市场分析计划可行性研究报告
- 家长课堂:五年级升学准备实操建议
- 2026-2027学年统编版九年级语文上册10月月考全真模拟卷原卷版
- 2025年全国成人高考(专升本)《政治》真题及答案(完整版)
- 2026秋新教材外研版(三起)小学英语六年级上册(全册)各单元达标测试卷及答案
- 市政工程安全隐患整改闭环管理培训
- 装配式叠合板安装监理实施细则
- 2026年北京市通州区辅警协警招聘考试备考试题及答案详解
- 七上科学经纬度专题
- 老年骨质疏松症患者跌倒预防循证指南(2026版)
- 2026年广西高职单招职业技能测试真题及参考答案
- 【2026】超星尔雅学习通《大学生恋爱与性健康(中国性学会)》章节测试及答案
- 2025年江西省人才发展集团有限公司招聘专题笔试真题
- 机械设备出厂检验记录表范本
评论
0/150
提交评论