摘要: 1.9 取中文日期显示——年月日时分 string strY=currentTime.ToString("f"); //不显示秒 1.10 取中文日期显示_年月 string strYM=currentTime.ToString("y"); 1.11 取中文日期显示_月日 string strMD=currentTime.ToString("m"); 1.12 取中文年月日 string strYMD=currentTime.ToString("D"); 1.13 取当前时分,格式为:14:24 string st 阅读全文
posted @ 2011-05-22 16:36 临河羡鱼 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 27、Remove() 从指定位置开始删除指定数的字符 字串对比一般都用: if(str1==str2){ } , 但还有别的方法: 1、 string str1; str2 //语法: str1.EndsWith(str2); __检测字串str1是否以字串str2结尾,返回布尔值.如: if(str1.EndsWith(str2)){ Response.Write("字串str1是以"+str2+"结束的"); } 2、 //语法:str1.Equals(str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上. 3、 //语法 阅读全文
posted @ 2011-05-22 16:35 临河羡鱼 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 23、字串对比一般都用: if(str1==str2){ } , 但还有别的方法: (1)、 string str1; str2 //语法: str1.EndsWith(str2); __检测字串str1是否以字串str2结尾,返回布尔值.如: if(str1.EndsWith(str2)){ Response.Write("字串str1是以"+str2+"结束的"); } (2)、 //语法:str1.Equals(str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上. (3)、 //语法 Equals(str1,str2); 阅读全文
posted @ 2011-05-22 16:34 临河羡鱼 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 19、(char)代码 把数字转为字符,查代码代表的字符。 如: Response.Write((char)22269); //返回“国”字。 20、 Trim() 清除字串前后空格 21 、字串变量.Replace("子字串","替换为") 字串替换 如: string str="中国"; str=str.Replace("国","央"); //将国字换为央字 Response.Write(str); //输出结果为“中央” 再如:(这个非常实用) string str="这是< 阅读全文
posted @ 2011-05-22 16:32 临河羡鱼 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 11、String str=Request.QueryString["变量"]; 用超链接传送变量。 如在任一页中建超链接:<a href=Edit.aspx?fbid=23>点击</a> 在Edit.aspx页中取值:String str=Request.QueryString["fdid"]; 12、DOC对象.CreateElement("新建节点名"); 创建XML文档新节点 13、父节点.AppendChild(子节点); 将新建的子节点加到XML文档父节点下 14、 父节点.RemoveChild( 阅读全文
posted @ 2011-05-22 16:30 临河羡鱼 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 5、System.Text.Encoding.Default.GetBytes(变量) 字码转换 转为比特码 如:byte[] bytStr = System.Text.Encoding.Default.GetBytes(str); 然后可得到比特长度: len = bytStr.Length; 6、System.Text.StringBuilder("") 字符串相加,(+号是不是也一样?) 如:System.Text.StringBuilder sb = new System.Text.StringBuilder(""); sb.Append(&qu 阅读全文
posted @ 2011-05-22 16:30 临河羡鱼 阅读(133) 评论(0) 推荐(0) 编辑
摘要: < 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 秒= 阅读全文
posted @ 2011-05-22 16:29 临河羡鱼 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 61. 除非你想重写子类中存在名称冲突的成员或者调用基类的构造函数否则不要使用base来访问基类的成员。// 正确使用base的例子public class Dog { public Dog(string name) {} virtual public void Bark( int howLong) {} } public class GermanShepherd : Dog { public GermanShe pherd(string name): base (name) {} override public void Bark(int howLong) { base .Bark(howL 阅读全文
posted @ 2011-05-22 11:07 临河羡鱼 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 51. 表现给最终用户的字符串不要使用硬编码而要使用资源文件替换之。52. 不要硬编码可能更改的基于配置的字符串,比如连接字符串。53. 当需要构建长的字符串的时候,使用StringBuilder不要使用string54. 避免在结构里面提供方法。a) 建议使用参数化构造函数b) 可以重裁操作符55. 总是要给静态变量提供静态构造函数。56. 能使用早期绑定就不要使用后期绑定。57. 使用应用程序的日志和跟踪。58. 除非在不完全的switch语句中否则不要使用goto语句。59. 在switch语句中总是要有default子句来显示信息(Assert)。int number = SomeMe 阅读全文
posted @ 2011-05-22 11:06 临河羡鱼 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 31. 总是使用基于0开始的数组。32. 在循环中总是显式的初始化引用类型的数组。public class MyClass {} MyClass[] array = new MyClass[100]; for(int index = 0; index < array.Length; index++) { array[index] = new MyClass(); } 33. 不要提供public 和 protected的成员变量,使用属性代替他们。34. 避免在继承中使用new而使用override替换。35. 在不是sealed的类中总是将public 和 protected的方法标记 阅读全文
posted @ 2011-05-22 11:05 临河羡鱼 阅读(136) 评论(0) 推荐(0) 编辑