在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1int x;
2String s; 3String s1, s2; 4Object o; 5Object obj = new Object(); 6public String name; 语句:
1Response.Write("foo");
注释 :
1// This is a comment
2 3*/ 访问索引属性:
1String s = Request.QueryString["Name"];
2String value = Request.Cookies["key"]; 声明索引属性:
1// Default Indexed Property
2} 声明简单属性:
1}
声明和使用枚举:
1// Declare the Enumeration
2 Small; 枚举集合:
1}
声明和使用方法:
1// Declare a void return function
2); 自定义属性:
1// Stand-alone attribute
2[STAThread] 3 4// Attribute with parameters 5[DllImport("ADVAPI32.DLL")] 6 7// Attribute with named parameters 8[DllImport("KERNEL32.DLL",CharSet=CharSet.Auto)] 数组:
1String[] a = new String[3];
2a[0] = "1"; 3a[1] = "2"; 4a[2] = "3"; 5 6String[][] a = new String[3][3]; 7a[0][0] = "1"; 8a[1][0] = "2"; 9a[2][0] = "3"; 初始化:
1String s = "Hello World";
2int i = 1; 3; If 语句:
1}
Case 语句:
1}
For 循环:
1for (int i=0; i<3; i++)
2 a(i) = "test"; While 循环:
1int i = 0;
2} 异常处理:
1}
字符串连接:
1// Using Strings
2String s1; 3String s2 = "hello"; 4s2 += " world"; 5s1 = s2 + " !!!"; 6 7// Using StringBuilder class for performance 8StringBuilder s3 = new StringBuilder(); 9s3.Append("hello"); 10s3.Append(" world"); 11s3.Append(" !!!"); 事件处理程序委托:
1void MyButton_Click(Object sender,
2} 声明事件:
1// Create a public event
2public event EventHandler MyEvent; 3 4// Create a method for firing the event 5} 向事件添加事件处理程序或从事件移除事件处理程序:
1Control.Change += new EventHandler(this.ChangeEventHandler);
2Control.Change -= new EventHandler(this.ChangeEventHandler); 强制类型转换:
1MyObject obj = (MyObject)Session["Some Value"];
2IMyObject iObj = obj; 转换:
1int i = 3;
2String s = i.ToString(); 3double d = Double.Parse(s); 带继承的类定义:
1using System;
2 3 library.cs 实现接口:
1}
带 Main 方法的类定义:
1using System;
2 3 csc /out:consolecs.exe /t:exe console.cs 标准模块:
1using System;
2 3 csc /out:consolecs.exe /t:exe console.cs |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论