摘要: 转自:http://www.cnblogs.com/Mainz/archive/2008/04/09/1144242.htmlstring类型转成byte[]:byte[]byteArray=System.Text.Encoding.Default.GetBytes(str);反过来,byte[]转成string:stringstr=System.Text.Encoding.Default.GetString(byteArray);其它编码方式的,如System.Text.UTF8Encoding,System.Text.UnicodeEncoding class等;例如:string类型转成 阅读全文
posted @ 2013-04-13 21:34 Cathy Lee 阅读(928) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/zftek/archive/2012/05/20/2510951.html-C#初学者经常被问的几道辨析题,值类型与引用类型,装箱与拆箱,堆栈,这几个概念组合之间区别,看完此篇应该可以解惑。 俗话说,用思想编程的是文艺程序猿,用经验编程的是普通程序猿,用复制粘贴编程的是2B程序猿,开个玩笑^_^。 相信有过C#面试经历的人,对下面这句话一定不陌生: 值类型直接存储其值,引用类型存储对值的引用,值类型存在堆栈上,引用类型存储在托管堆上,值类型转为引用类型叫做装箱,引用类型转为值类型叫拆箱。 但仅仅背过这句话是不够的。 C#程序员不必手... 阅读全文
posted @ 2013-04-13 16:33 Cathy Lee 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/tangge/archive/2012/09/06/2674166.html#C1.如果要执行增删改和单个值查询的时候,可以直接让【车间工人】去【中央仓库】做。2.如果要从【中央仓库】查询多行货物的时候,有两种方式: 2.1可以选择叫一辆【货运卡车】去搬,卡车可以一次性的都搬过来,但【生产车间】一下子用不了,所以卡车就把货先放在【车间临时仓库】,这样车间需要的时候直接拿就可以了。 2.2可以让【车间工人】把自己的【摩托车】拿来,骑【摩托车】去仓库拿货,但每次只能拿一行货物,所以需要往返的拿很多次才能拿完。但因为每次只拿一行货物过来,车间就直接 阅读全文
posted @ 2013-04-13 15:45 Cathy Lee 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/jackal/archive/2011/04/29/2032613.html深复制(deep copy)和浅复制(shallow copy)都是用于对象之间的拷贝。 注:参考CodeProject浅复制:创建一个新对象, 然后将当前对象的非静态字段拷贝到新对象.如果字段是值类型的, 在堆栈上开辟一个新的空间, 将该字段进行逐位复制到新空间.如果字段是引用类型的, 在堆栈区域开辟一个存放引用的空间, 将当前对象的引用复制到此空间, 而引用的对象不变. 因此, 原始对象及其复本引用同一对象。在C#中创建一个浅表副本, 也就是克隆一个新的对象 使用 阅读全文
posted @ 2013-04-13 15:35 Cathy Lee 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/Dlonghow/archive/2008/08/04/1259732.htmlReferenceEquals,==,Equals比较ReferenceEquals, == , Equals Equals , == , ReferenceEquals都可以用于判断两个对象的个体是不是相等。 a) ReferenceEqualsReferenceEquals是Object的静态方法,用于比较两个引用类型的对象是否是对于同一个对象的引用。对于值类型它总是返回false。(因为Box以后的对象总是不同的,hehe) b) ==是一个可以重载的二元操 阅读全文
posted @ 2013-04-13 14:36 Cathy Lee 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Data; 6 7 namespace TestSample 8 { 9 10 #region explaination 17 18 19 //一、冒泡排序 20 21 //已知一组无序数据a[1]、a[2]、……a[n],需将其按升序排列。首先比较a[1]与a[2]的值,若a[1]大于a[2]则交换两者的值,否则不变。再比... 阅读全文
posted @ 2013-04-13 13:52 Cathy Lee 阅读(275) 评论(0) 推荐(0) 编辑
摘要: 转自:http://www.cnblogs.com/lichang1987/archive/2009/03/04/1403166.html最近在公司里做项目,遇到一个问题,建的数据库里的中文字符和音标显示为乱码,组里的人所有字符都用varchar表示,所以出现上诉问题,当改为Nvarchar后,问题得到解决。所以有必要把他们的区别再重新复习一遍。 char类型:对英文(ASCII)字符占用1个字节,对一个汉字占用2个字节,CHAR存储定长数据很方便,CHAR字段上的索引效率级高,比如定义char(10),那么不论你存储的数据是否达到了10个字节,都要占去10个字节的空间。因为是固定长度,所以速 阅读全文
posted @ 2013-03-19 16:11 Cathy Lee 阅读(178) 评论(0) 推荐(0) 编辑
摘要: View Code 1 public static string[] casttoarray(string strLine) 2 { 3 List<string> parsedData = new List<string>(); 4 bool tokenInQuotes = false; 5 bool tokenContinued = true; 6 string temp_println = ""; 7 string printLine =... 阅读全文
posted @ 2013-03-19 15:24 Cathy Lee 阅读(170) 评论(0) 推荐(0) 编辑
摘要: Although the .net framework contains all kinds of exception types which are sufficient in most cases, it can make sense to define custom exception in our own application. They can greatly simplify and imprve the error handling.Custom exception derive from Exception calss.Define custom exception cals 阅读全文
posted @ 2013-03-19 15:13 Cathy Lee 阅读(354) 评论(0) 推荐(0) 编辑
摘要: An error is a mistake is coding on the part of the programmer, so the program won't give the desired result.For exampile, in ASP.NET there are different types of error:1. Configuration error: these error arise when the web.config or machine.config files are not formed properly.2. Compilation err 阅读全文
posted @ 2013-03-19 11:56 Cathy Lee 阅读(190) 评论(0) 推荐(0) 编辑