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

看板C_Sharp (C#)作者 (Op穎)時間20年前 (2005/04/14 23:36), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/4 (看更多)
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(); } } -- 我的Blog :) http://spaces.msn.com/members/austinjan/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.160.120.62
文章代碼(AID): #12Net_hg (C_Sharp)
文章代碼(AID): #12Net_hg (C_Sharp)