常用函数:C#.net常用函数和办法集总结来源: 发布时间:星期四, 2009年2月12日 浏览:152次 评论:0
1、DateTime 数字型 ![]() ![]() ![]() ![]() 1.1 取当前年月日时分秒 currentTime= ![]() 1.2 取当前年 ![]() 1.3 取当前月 ![]() 1.4 取当前日 ![]() 1.5 取当前时 ![]() 1.6 取当前分 ![]() 1.7 取当前秒 ![]() 1.8 取当前毫秒 ![]() (变量可用中文) 2、Int32.Parse(变量) Int32.Parse(\"常量\") ![]() 3、 变量. ![]() ![]() ![]() ![]() 12345. ![]() 12345. ![]() 12345. ![]() 12345. ![]() 12345. ![]() 12345. ![]() 4、变量.Length 数字型 取字串长度: 如: ![]() ![]() ![]() ![]() ![]() 5、 ![]() 字码转换 转为比特码 如: ![]() ![]() ![]() 然后可得到比特长度: len = bytStr.Length; 6、 ![]() ![]() ![]() ![]() 如: ![]() ![]() ![]() sb.Append(\"中华\"); sb.Append(\"人民\"); sb.Append(\"共和国\"); 7、变量.Sub ![]() 截取字串 ![]() ![]() ![]() ![]() ![]() 如: ![]() ![]() 8、String user_IP=Request.ServerVariables[\"REMOTE_ADDR\"]. ![]() ![]() 取远程用户IP地址 9、穿过代理服务器取远程用户真实IP地址: ![]() ![]() ![]() ![]() } ![]() ![]() ![]() ![]() } 10、 Session[\"变量\"]; 存取Session值; 如 ![]() 取值: Object objName=Session[\"username\"]; String strName=objName. ![]() ![]() 清空: Session.RemoveAll ![]() [Page] 11、String str=Request.QueryString[\"变量\"]; 用超链接传送变量 ![]() 如在任 ![]() 在Edit.aspx页中取值:String str=Request.QueryString[\"fdid\"]; 12、DOC对象.CreateElement(\"新建节点名\"); 创建XML文档新节点 13、父节点.AppendChild(子节点); 将新建 ![]() 14、 父节点.RemoveChild(节点); 删除节点 15、Response Response.Write(\"字串\"); Response.Write(变量); 向页面输出 ![]() Response.Redirect(\"URL地址\"); 跳转到URL指定 ![]() 16、char.IsWhiteSpce(字串变量 ![]() 查指定位置是否空 ![]() 如: ![]() Response.Write(char.IsWhiteSpace(str,2)); //结果为:True, 第 ![]() ![]() ![]() ![]() ![]() 17、char.IsPunctuation(\' ![]() 查 ![]() 如:Response.Write(char.IsPunctuation(\'A\')); //返回:False 18、( ![]() ![]() 把 ![]() ![]() ![]() ![]() 如: Response.Write(( ![]() ![]() 19、(char)代码 把数字转为 ![]() ![]() ![]() ![]() ![]() 如: Response.Write((char)22269); //返回“国”字 ![]() 20、 Trim ![]() 清除字串前后空格 21 、字串变量.Replace(\"子字串\",\"替换为\") 字串替换 如: ![]() str=str.Replace(\"国\",\"央\"); //将国字换为央字 Response.Write(str); //输出结果为“中央” 再如:(这个非常实用) ![]() 0
相关文章读者评论发表评论 |
|