摘要: 摘自:http://www.cnblogs.com/nzbbody/archive/2012/09/05/2671819.htmlC# 相等性判断有四个方法:1 public static bool ReferenceEquals(object left, object right);2 public static bool Equals(object left, object right);3 public virtual bool Equals(object right);4 public static bool operator ==(MyClass left, MyClass righ 阅读全文
posted @ 2013-11-07 14:14 nygfcn 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 参考:http://blog.sina.com.cn/s/blog_63f15e560100hzp6.htmlhttp://blog.csdn.net/xqiangqiang/article/details/5287447首先:总结一下(xxx)和xxx.Parse(),Convert.xxx(),xxx.TryParse(string, out xx)的区别:(int)转换:用在数值范围大的类型转换成数值范围小的类型时使用,但是如果被转换的数值大于或者小于数值范围,则得到一个错误的结果,利用这种转换方式不能将string转换成int,会报错。Int32.Parse(),转换:在符合数字格式的 阅读全文
posted @ 2013-11-07 10:31 nygfcn 阅读(1514) 评论(0) 推荐(0) 编辑
摘要: 摘自:http://www.cnblogs.com/Kenny-Jiang/archive/2008/05/26/1207969.htmlC#中有两种常量类型,分别为readonly(运行时常量)与const(编译时常量),本文将就这两种类型的不同特性进行比较并说明各自的适用场景。工作原理 readonly为运行时常量,程序运行时进行赋值,赋值完成后便无法更改,因此也有人称其为只读变量。 const为编译时常量,程序编译时将对常量值进行解析,并将所有常量引用替换为相应值。 下面声明两个常量:publicstaticreadonlyintA=2;//A为运行时常量publicconstintB= 阅读全文
posted @ 2013-11-07 09:54 nygfcn 阅读(256) 评论(0) 推荐(0) 编辑