看板 C_Sharp 關於我們 聯絡資訊
SortedList好像會按照字母排序 也因為這樣Sorted好像會執行比較慢 有沒有辦法將先插入的索引就是0 第二個插入的就1,以此類推 而不會自動幫你排序... : using System; : using System.Collections; : public class SamplesSortedList { : public static void Main() { : // Creates and initializes a new SortedList. : SortedList mySL = new SortedList(); : mySL.Add("First", "Hello"); : mySL.Add("Second", "World"); : mySL.Add("Third", "!"); : // Displays the properties and values of the SortedList. : Console.WriteLine( "mySL" ); : Console.WriteLine( " Count: {0}", mySL.Count ); : Console.WriteLine( " Capacity: {0}", mySL.Capacity ); : Console.WriteLine( " Keys and Values:" ); : PrintKeysAndValues( mySL ); : } : public static void PrintKeysAndValues( SortedList myList ) { : Console.WriteLine( "\t-KEY-\t-VALUE-" ); : for ( int i = 0; i < myList.Count; i++ ) : { : Console.WriteLine( "\t{0}:\t{1}", myList.GetKey(i), myList.GetByIndex(i) ); : } : Console.WriteLine(); : } : } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.62.240.26
virdust2003:arraylist 140.113.164.7 04/16