<%@page language="vb" %>
<script runat="server" language="vb">
sub page_load()
dim animalarray(4) as string
dim stranimal as string
animalarray(0)="dog"
animalarray(1)="cat"
animalarray(2)="elephant"
animalarray(3)="lion"
animalarray(4)="cat"
array.reverse(animalarray) ‘显示错误
array.sort(animalarray) ‘也说有错
for each stranimal in animalarray
mydropdownlist.items.add(stranimal)
next
end sub
</script><html>
<form id="form1" method="post" runat="server">
<asp:dropdownlist id="mydropdownlist" runat="server"/>
</form>
</html>
<script runat="server" language="vb">
sub page_load()
dim animalarray(4) as string
dim stranimal as string
animalarray(0)="dog"
animalarray(1)="cat"
animalarray(2)="elephant"
animalarray(3)="lion"
animalarray(4)="cat"
array.reverse(animalarray) ‘显示错误
array.sort(animalarray) ‘也说有错
for each stranimal in animalarray
mydropdownlist.items.add(stranimal)
next
end sub
</script><html>
<form id="form1" method="post" runat="server">
<asp:dropdownlist id="mydropdownlist" runat="server"/>
</form>
</html>
public class SamplesArray { public static void Main() { // Creates and initializes a new Array.
Array myArray=Array.CreateInstance( typeof(String), 9 );
myArray.SetValue( "The", 0 );
myArray.SetValue( "QUICK", 1 );
myArray.SetValue( "BROWN", 2 );
myArray.SetValue( "FOX", 3 );
myArray.SetValue( "jumps", 4 );
myArray.SetValue( "over", 5 );
myArray.SetValue( "the", 6 );
myArray.SetValue( "lazy", 7 );
myArray.SetValue( "dog", 8 ); // Displays the values of the Array.
Console.WriteLine( "The Array initially contains the following values:" );
PrintIndexAndValues( myArray ); // Reverses the sort of the values of the Array.
Array.Reverse( myArray, 1, 3 ); // Displays the values of the Array.
Console.WriteLine( "After reversing:" );
PrintIndexAndValues( myArray );
}
public static void PrintIndexAndValues( Array myArray ) {
for ( int i = myArray.GetLowerBound(0); i <= myArray.GetUpperBound(0); i++ )
Console.WriteLine( "\t[{0}]:\t{1}", i, myArray.GetValue( i ) );
}
}