Re: [問題] 是否可用字串索引

看板C_Sharp (C#)作者 (御神者)時間20年前 (2005/04/15 16:27), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串3/4 (看更多)
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

140.113.164.7 04/16, , 1F
arraylist
140.113.164.7 04/16, 1F
文章代碼(AID): #12NtiC6F (C_Sharp)
討論串 (同標題文章)
文章代碼(AID): #12NtiC6F (C_Sharp)