摘要:
IComparable<T>通过T,可以实现保证传入的对对象类型是确定的,这样在编译时就可以确定类型了,如下的注释的那句,现在只能传入Person类型,这样保证类型是安全的,不必过多的进行Convert[代码]
阅读全文
posted @ 2008-12-02 18:21
云者悟空
阅读(478)
推荐(0)
编辑
摘要:
将ICompareable和IComparer结合 比较大小这儿注意的是PersonComparer的比较方法 CompareTo调用了Person对象的重载比较方法CompareTO public int CompareTo(object obj, PersonCompareType compareType){.....}这样的话,Person能根据Comparer传过来的参数,进行相应的排序比...
阅读全文
posted @ 2008-12-02 18:01
云者悟空
阅读(290)
推荐(0)
编辑
摘要:
实现IComparer ,这样就可以在数组中或其它集合中自定义排序了,要实现其中的方法: public int Compare(object x, object y) Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using Syst...
阅读全文
posted @ 2008-12-02 17:27
云者悟空
阅读(426)
推荐(0)
编辑
摘要:
实现ICompareable,使对象具有自定义的比较功能,只要实现其的一个方法(CompareTo)就可以了 Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System; using System.Collections;/...
阅读全文
posted @ 2008-12-02 17:14
云者悟空
阅读(231)
推荐(0)
编辑
摘要:
实现ICollection 注意: ICollection inherits IEnumerable Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System; using System.Collections;//注意us...
阅读全文
posted @ 2008-12-02 16:24
云者悟空
阅读(426)
推荐(0)
编辑
摘要:
Code Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System; using System.Collections;//注意using Collections using System.Collections.Generic; ...
阅读全文
posted @ 2008-12-02 14:40
云者悟空
阅读(913)
推荐(0)
编辑