访华车队视频:Asp.Nne 编程常用的二十六个函数详解-程序开发-红黑联盟

来源:百度文库 编辑:九乡新闻网 时间:2024/10/06 00:24:39

Asp.Nne 编程常用的二十六个函数详解
 
 
文章录入:7747.Net    责任编辑:7747.Net  10 
 【字体:小 大】
 
1、DateTime 数字型
以下是引用片段:
System.DateTime currentTime=new System.DateTime();
1.1 取当前年月日时分秒 currentTime=System.DateTime.Now;
1.2 取当前年 int 年=currentTime.Year;
1.3 取当前月 int 月=currentTime.Month;
1.4 取当前日 int 日=currentTime.Day;
1.5 取当前时 int 时=currentTime.Hour;
1.6 取当前分 int 分=currentTime.Minute;
1.7 取当前秒 int 秒=currentTime.Second;
1.8 取当前毫秒 int 毫秒=currentTime.Millisecond;
(变量可用中文)

2、Int32.Parse(变量) Int32.Parse("常量")
以下是引用片段:
字符型转换 转为32位数字型

3、 变量.ToString()
以下是引用片段:
字符型转换 转为字符串
12345.ToString("n"); //生成 12,345.00
12345.ToString("C"); //生成 ¥12,345.00
12345.ToString("e"); //生成 1.234500e 004
12345.ToString("f4"); //生成 12345.0000
12345.ToString("x"); //生成 3039 (16进制)
12345.ToString("p"); //生成 1,234,500.00%

4、变量.Length 数字型
以下是引用片创建XML文档新节点

13、父节点.AppendChild(子节点);
以下是引用片段:
将新建的子节点加到XML文档父节点下

14、 父节点.RemoveChild(节点);
以下是引用片段:
删除节点

15、Response
以下是引用片段:
Response.Write("字串");
Response.Write(变量);
向页面输出。
Response.Redirect("URL地址");
跳转到URL指定的页面

16、char.IsWhiteSpce(字串变量,位数)——逻辑型
以下是引用片段:
查指定位置是否空字符;
如:
string str="中国 人民";
Response.Write(char.IsWhiteSpace(str,2)); //结果为:True, 第一个字符是0位,2是第三个字符。

17、char.IsPunctuation('字符') --逻辑型
以下是引用片段:
查字符是否是标点符号
如:Response.Write(char.IsPunctuation('A')); //返回:False

18、(int)'字符'
以下是引用片段:
把字符转为数字,查代码点,注意是单引号。
如:
Response.Write((int)'中'); //结果为中字的代码:20013

19、(char)代码
以下是引用片段:
把数字转为字符,查代码代表的字符。
如:
Response.Write((char)22269); //返回“国”字。

20、 Trim()
以下是引用片段:
清除字串前后空格

21 、字串变量.Replace("子字串","替换为")
以下是引用片段:
字串替换
如:
string str="中国";
str=str.Replace("国","央"); //将国字换为央字
Response.Write(str); //输出结果为“中央”
再如:(这个非常实用)
string str="这是