SortedList的使用舉例

2021-05-26 14:51:33 字數 901 閱讀 3274

/*

* created by sharpdevelop.

* user: administrator

* date: 2011-7-12

* time: 7:42

* * to change this template use tools | options | coding | edit standard headers.

*/using system;

using system.collections;

namespace test

",mysl.count);

console.writeline("\tcapacity: ",mysl.capacity);

console.writeline("\tkeys and values: ");

printkeysandvalues(mysl);

console.write("press any key to continue . . . ");

console.readkey(true);

} public static void printkeysandvalues(sortedlist mylist)

{ console.writeline("\t-key-\t-value-");

for (int i = 0;i/*

this code produces the following output.

mysl

count:    3

capacity: 16

keys and values:

-key-    -value-

first:    hello

second:    world

third:    !

*/

SortedList 的初步使用

class program console.writeline var linqvalue from d in sortedlist orderby d.keydescending select d foreach keyvaluepair int,string value in linqvalue...

SortedList重複鍵的實現

net中是用乙個compare函式來對新增到集合中的鍵進行比較的,只要這個函式返回的值不等於0,就可以正常向集合新增資料 using system using system.collections namespace testsortedlist private static void printl...

SortedList 儲存鍵值對的集合

創 建乙個sortedlist機會用於儲存基於鍵上值排序的鍵值對。可以通過如下屬性獲得sortedlist的唯讀的keys和 values值。public virtual icollection keys public virtual icollection values 下面是sortedlist...