Archive

Archive for December, 2005

Professional C# 学习笔记之集合

December 31st, 2005
Comments Off

1.ArrayList有点像动态数组。
2.集合:实现System.Collections.IEnumerable。
3.IEnumerable实现一个方法GetEnumerator,返回IEnumerator。
4.Ienumerator有三个成员,current返回集合中的当前对象;MoveNext方法:移动到集合的下一元素上,如果成功下移,返回true,如果已过最后一个元素,返回false;Reset方法:移动到第一个元素前面(注意不是第一个!)。
5.如果键是字符串,可用System.Collections.Specialized.StringDictionary来代替Hashtable。
6.在字典使用内部算法时,如果容量是一个素数,它们的工作效率最高。
7.如果A.Equals(B)是True,则A.GetHashCode()和B.GetHashCode()必须返回相同的散列。
8.一般来说,做键的对象都要重写Equals()和GetHashTable(),因为System.Object.Equals()仅比较引用,GetHashTable()会根据对象的地址返回一个散列。则只有键是相同的对象时,才是相等的。
9.Microsoft已经为String类提供了一种虽然复杂、但很有效的散列算法。如果要自己设计散列算法,有一个简单方法,把对象中表示对象唯一性的成员字段们的数字乘以不同的素数再加起来。

Technorati : ,

Administrator i.t.

Professional C# 学习笔记之字符串和正则表达式

December 30th, 2005
Comments Off

1.System.String类进行文字处理,效率不佳。System.Text.StringBulider更适合文字处理。
2.IFormattable接口,自定义格式化字符串。
3.正则表达式和Jscript的正则表达式类似。规则较繁,用时再查MSDN。

Technorati : ,

Administrator i.t.

Professional C# 学习笔记之内存管理和指针

December 29th, 2005
Comments Off

1.stack存储值数据类型,heap存储引用数据类型。
2.引用分配在stack上,而引用所对应的实例分配在heap上。
3.垃圾收集器在释放了它能释放的所有对象后,就会压缩其他对象,把他们都移动回heap的端部,再次形成一个连续的块。
4.有析构函数的对象需要垃圾收集器两次处理才能删除:第一次调用析构函数时,没有删除对象,第二次调用才真正删除对象。
5.由于垃圾收集器的工作方式,无法确定C#对象的析构函数何时执行。
6.可实现IDisposable接口的Dispose()来显示释放由对象使用的所有未托管资源。
7.要用指针,请先用unsafe标记。Unsafe可以标记方法、类、结构、成员和代码块,但不能标记局部变量。
8.C#中int* pX,pY等价于C++中 int *pX,*pY。
9.不允许针对void指针执行算术运算。
10.sizeof只能用于不安全代码块,且不能对类使用。
11.不能创建指向类的指针,这是因为垃圾收集器不包含指针的任何信息,只包含引用的信息,因此创建指向类的指针会使垃圾收集器不能正常工作。
12.int* pX = &(myObject.X);这样的表达式是错误的,因为在垃圾收集的过程中,垃圾收集器会把myClass移动到内存的一个新单元,这样,pX会指向错误的存储单元。解决方法是使用fixed关键字。fixed(int* pX=&(myObject.X))(//do something}。这样,垃圾收集器知道,在执行fixed块的代码是,不能移动myObject对象。
13.创建基于stack的数组。int* pInt = stackalloc int [10];

Technorati : ,

Administrator i.t.

Stay Hungry, Stay Foolish

December 29th, 2005
Comments Off

This is some of my favorate passages of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005 at Stanford University.

Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.

Again, you can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something – your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.

I’m convinced that the only thing that kept me going was that I loved what I did. You’ve got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don’t settle.

When I was 17, I read a quote that went something like: “If you live each day as if it was your last, someday you’ll most certainly be right.” It made an impression on me, and since then, for the past 33 years, I have looked in the mirror every morning and asked myself: “If today were the last day of my life, would I want to do what I am about to do today?” And whenever the answer has been “No” for too many days in a row, I know I need to change something.

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma – which is living with the results of other people’s thinking. Don’t let the noise of other’s opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become.
Everything else is secondary.

Technorati : ,

Administrator essays

some pictures of benq china

December 29th, 2005
Comments Off

benq dorm smoking area

pictured by 枫之舞
for more picutures of benq, please visit my flickr

Technorati :

Administrator essays