default.aspx

来自「Professional ASP.NET source code」· ASPX 代码 · 共 60 行

ASPX
60
字号
<%@Page Language="C#" %>

<%

SortedList alphabet = new SortedList();

alphabet = CollectionsUtil.CreateCaseInsensitiveSortedList();

alphabet.Add( "Z", "The Letter Z" );
alphabet.Add( "A", "The Letter A" );
alphabet.Add( "S", "The Letter S" );

Response.Write("<h3>A sorted list</h3>");

foreach( DictionaryEntry letter in alphabet )
{
	Response.Write( "<BR>" + letter.Key + " - " + letter.Value);
}

Response.End();

Hashtable names = new Hashtable();

names.Add( "RA", "Richard Anderson" );
names.Add( "DS", "David Sussman" );
names.Add( "RH", "Rob Howard" );
names.Add( "AH", "Alex Homer" );
names.Add( "KW", "Karli Watson" );
names.Add( "BF", "Brian Francis" );


Response.Write("<h3>Unsorted list</h3>");

foreach( DictionaryEntry name in names )
{
	Response.Write( "<BR>" + name.Key + " - " + name.Value);
}


Response.Write("<h3>Sorted list</h3>");

// Create a sorted copy of the list 

SortedList sortedNameList = new SortedList( names );

foreach( DictionaryEntry name in sortedNameList )
{
	Response.Write( "<BR>" + name.Key + " - " + name.Value);
}

// Create a sorted copy of the list 

//foreach( string name in sortedNameList.GetValueList() )
//{
//	Response.Write( "<BR>" + name );
//}


%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?